dllimport

Frame Capture using Matrox Commands

雨燕双飞 提交于 2019-12-06 01:54:19
I'm working on a project where I have to set the fps of a video stream (as 10) from a camera and grab a frame every 5th frame. I'm working on a program that has already been half written by someone else. The thing is, they have used Matrox Framegrabber dlls. There is also Matrox Frame Grabber on the device. But I cant find any commands for framegrab in C#. I found the following code for C++. MIL_ID MdispAlloc(SystemId, DispNum, DispFormat, InitFlag, DisplayIdPtr) where MIL_ID SystemId; System identifier long DispNum; Display number char *DispFormat; Display format name or file name long

Use GetForegroundWindow result in an if statement to check user's current window

怎甘沉沦 提交于 2019-12-06 01:33:54
问题 I need to check what window the user currently has selected, and do stuff if they have a specific program selected. I haven't used the GetForegroundWindow function before, and can't find any information on how to use it in this manner. I simply need an if comparing the current window to see if its a specific program. However the GetForegroundWindow function doesn't give back a string or int it seems. So mainly I don't know how to find out the value of the program window I want to compare it

Can different versions of DLL be loaded in same application?

血红的双手。 提交于 2019-12-06 00:59:50
问题 My application uses one version of library (a.dll), I am using another DLL(b.dll) which in-turn uses older version of the same library (a.dll) that i use. I am building the application by embedding a manifest file. The DLL i use is also using a embedded manifest file. I am having both the versions of the library in my WinSXS folder. My application is not able to load the appropriate versions of DLLs. Will having a separate manifest file (not embedding into DLL) help resolving the problem?

Using DLLImport to import a class

邮差的信 提交于 2019-12-05 22:44:24
I have an class in dll: For example: namespace foo { public class baa { /* ... */ } } how can I imports the baa class from dll? it is possible? [DllImport(DllName)] public extern ?? foo() ?? Thanks in advance. That's not going to work. Unmanaged DLLs export a C interface, not a C++ one. And for managed DLLs (C# or C++/CLI) you simply don't need DllImport. Only functions that are imported into a static class I'm afraid. DllImport is used only when you want to invoke unmanaged functions from an unmanaged library (like one written in C++). When you have a managed .NET assembly you simply add it

Win 7 DllImport C# Odd error, Invalid access to memory location?

可紊 提交于 2019-12-05 22:39:27
问题 I am using DllImport to access some functions in a C++ dll from my C# application. This code works fine on my dev laptop, which is Windows 7 64bit, the dll itself is 32 bit, so I run the process hosting the dll in 32bit and it works well. However when I try to run the exact same process on my target machine, which is again, Windows 7 64bit Ultimate i get the error 'Invalid access to memory location.' from the process. I'm not sure what the problem is, i've looked at loads of resources on the

How can i set an entrypoint for a dll

那年仲夏 提交于 2019-12-05 20:08:55
问题 First i thought entry point in dlls DLLMain but then when i try to import it in C# i get an error that entrypoint wasn't found Here is my code: #include <Windows.h> int Test(int x,int y) { return x+y; } BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: MessageBox(0,L"Test",L"From unmanaged dll",0); case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; } How can

How to import void * C API into C#?

北城以北 提交于 2019-12-05 19:24:15
问题 Given this C API declaration how would it be imported to C#? int _stdcall z4ctyget(CITY_REC *, void *); I've been able to get this far: [DllImport(@"zip4_w32.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "z4ctygetSTD", ExactSpelling = false)] private extern static int z4ctygetSTD(ref CITY_REC args, void * ptr); Naturally in C# the "void *" doesn't compile. Some Googling indicates that it should be translated as "object." Which seems like it should work. But others indicate

C# delegate for C++ callback

人走茶凉 提交于 2019-12-05 15:44:24
问题 I think I have basically understood how to write c# delegates for callbacks, but this one is confusing me. The c++ definition is as follows: typedef int (__stdcall* Callback)( long lCode, long lParamSize, void* pParam ); and my c# approach would be: unsafe delegate int CallbackDelegate (int lCode, int lParamSize, IntPtr pParam); Although this seems to be incorrect, because I get a PInvokeStackInbalance error, which means my definition of the delegate is wrong. The rest of the parameters of

Windows 8 printing Postscript file programmatically

情到浓时终转凉″ 提交于 2019-12-05 14:32:50
I've spotted a strange problem while printing a Postscript file . So here is my setup: I have a Windows 8 PC , on this PC there is an C# application "NetworkPrintTest.exe", which, when executed, should open a PDF, generate a Postscript file and ultimately should print it. But it doesn't do anything. I don't get an error but it won't print either. The same program runs error free on windows 7 and i even get the printer to print the file. As mentioned above the .ps file is generated successfully on both operating systems but the printing failes. Here is my source code which should print the file

C# Marshalling char** and unsigned char**

↘锁芯ラ 提交于 2019-12-05 12:43:43
Here is the problem - i have some C image processing library that i need to use from C# application. Lack of experience with DllImport strikes me hard for now. The function i need to use looks like: IMAGEPROCESS_API const int importImage ( const unsigned char* image, const char* xmlInput, unsigned char** resultImage, char** xmlOutput ); So, it accepts raw image data, xml containing parameters and image width'height and then return processed image and some xml report. For now im trying to approach it like this: [DllImport("imageprocess.dll",CallingConvention = CallingConvention.StdCall