dllimport

Trouble with C#<->C++ DLLImport “Attempted to read or write protected memory.”

♀尐吖头ヾ 提交于 2019-12-12 10:43:13
问题 I have a C++ dll which has a function within it I am trying to call from a C# application. Here's the code in the C++ header file extern "C" _declspec(dllexport) int LabelStoringSSDsim(int devNum, UCHAR serial[40], UCHAR wwn[40], UCHAR ConfigID[5], UCHAR FrmRev[8], UCHAR DevName[40], int eCode); Here's the code in the C++ source file int LabelStoringSSDsim(int devNum, UCHAR serialLbl[40], UCHAR wwnLbl[40], UCHAR ConfigID[5], UCHAR FrmRev[8], UCHAR DevName[40], int eCode) { string strConfigID=

Using dllimport with Visual C++

穿精又带淫゛_ 提交于 2019-12-12 10:08:14
问题 I've not done any windows programming for a few years now and I'm a bit rusty on how to use dllimport. I have something along the lines of: extern "C" { __declspec(dllimport) int myFunct(); } int main() { cout<<myFunct(); } I get 2 unresolved externals linker errors and a warning that /DELAYLOAD:myLib.dll was ignored because no imports from it were found. What am I missing here? I thought that I can add the DLL to the delay load path, and the linker will figure to use it for the dll import??

How to control the execution of an externl native DLL

大憨熊 提交于 2019-12-12 07:00:36
问题 I have this code in .NET: result = NativeMethods.gsapi_init_with_args(_ghostScriptInstance, args.Length, _argumentPointersHandle.AddrOfPinnedObject()); That in its turn executes this code [DllImport("C:\\gsdll64.dll", EntryPoint = "gsapi_init_with_args")] public static extern int gsapi_init_with_args(IntPtr instance, int argc, IntPtr argv); The problem is that because of yet unknown problem the native execution enters into an infinite loop and never returns. The question is how can I cap the

The program can't start because MSVCR80D.dll

不问归期 提交于 2019-12-12 04:39:46
问题 I have made a dll in Microsoft Visual Studio 2005. Then i am trying to use it in other project on the other computer in CodeBlocks IDE. Project is built, but when it use functions from dll i got an error: "The program can't start because MSVCR80D.dll is missing from your computer. Try reinstall the program to fix this problem". How to build my dll without dependences on MSVCR80D.dll or build in this MSVCR80D.dll? 回答1: You're trying to run a debug version, which is linked to the debug version

user32 GetClassName isn't correct

旧城冷巷雨未停 提交于 2019-12-12 04:24:48
问题 I have a routine that get's all open windows (processes) and then searches for it's classname with the GetClassName method in user32. But when for example Teamviewer is on the classnames of all applications get the teamviewer classname. Example: Notepad is open and TeamViewer on classname: 'TeamViewer_TitleBarButtonClass' Notepad is open and TeamViewer off classname: 'Notepad' I looked how this came and found out that Teamviewer puts a control on top of some application windows. So how can i

C# IFileOperation How to get status and error information for all operations

扶醉桌前 提交于 2019-12-12 03:19:44
问题 I would like to use IFileOperation in my .NET C# application. I found this article http://blogs.msdn.com/b/msdnmagazine/archive/2007/12/12/6738569.aspx (source code is available here http://download.microsoft.com/download/f/2/7/f279e71e-efb0-4155-873d-5554a0608523/NetMatters2007_12.exe). It is working well so far but I want to get status and error information for all operations. There is line of code: if (_callbackSink != null) _sinkCookie = _fileOperation.Advise(_callbackSink); which should

Unable to load DLL The specified module could not be found

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 02:57:59
问题 When using [DllImport("my.cool.library")] with .NET you get an error similar to the following: "Unable to load DLL... The specified module could not be found..." ...even though all the required DLLs are in place and clearly accessible!? 回答1: Turns out DLLImport only assumes the ".dll" extension if you do not have periods in the name. If DLLImport("my.cool.library.dll") was used, it would work, otherwise the DLL will have to be renamed to "my_cool_library.dll", and then DLLImport("my_cool

Using OPL CPLEX in Excel VBA?

橙三吉。 提交于 2019-12-12 02:51:58
问题 I'd like to call OPL CPLEX and solve problems in a program coded on Excel VBA. I want to create an OPL model and, load .mod and .dat file into that model. After a long search process on the internet, I came up with some lines of script below released on IBM website. Sub CPLEXCallHere() 'To create the Concert environment Dim oplF As Oplfactory 'To create the error handler Dim errorHandler As OplErrorHandler 'To identify the model source Dim modelSource As OplModelSource 'To identify the model

How to get around DnsRecordListFree error in .NET Framework 4.0?

时间秒杀一切 提交于 2019-12-12 02:44:32
问题 I am doing an MxRecordLookup. I am getting an error when calling the DnsRecordListFree in the .NET Framework 4.0. I am using Windows 7. How do I get around it? Here is the error: Faulting application name: MxRecordService.exe, version: 1.0.0.0, time stamp: 0x4ce25848 Faulting module name: ntdll.dll, version: 6.1.7600.16559, time stamp: 0x4ba9b802 Exception code: 0xc0000374 Fault offset: 0x00000000000c6df2 Faulting process id: 0x110c Faulting application start time: 0x01cb85f46c1140da Faulting

Overflow Errors in 64-bit Windows Server 2012 after Upgrade to .NET Framework?

我怕爱的太早我们不能终老 提交于 2019-12-12 01:52:22
问题 Our solution was recently upgraded from .NET Framework v3.5 to v4.5.2 and as a result we have had some overflow errors running on Windows Server 2012 64-bit machines. These overflow errors seem to be coming from any instance where we call this function from the Windows API: [DllImport("user32.dll", CharSet=CharSet.Auto)] public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, IntPtr lParam); The overflow was happening because for lParam in some instances, for whatever reason