i have a MFC dll from a video capturer SDK which i want to use in C#. it was defined in MFC function with a class named AVEControl. i have not the source code of the Dll but only the head file as below. if i use [DllImport] directly, an runtime exception is shown with the message "can not found the entrypoint in *.dll". i guess it was because all function is in the class so i can not call it directly. so i want to know how to wrapper it with VC++.net or otherwise. !!!please notice the DEFINE of CLASS!!! // AVEControl.h: interface for the AVEControl class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_AVECONTROL_H__4E171B4B_A11B_49F1_B41C_5F4A31B5CF08__INCLUDED_) #define AFX_AVECONTROL_H__4E171B4B_A11B_49F1_B41C_5F4A31B5CF08__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #ifdef DEVICECONTROL_EXPORTS #define DEVICECONTROL_API __declspec(dllexport) #else #define DEVICECONTROL_API __declspec(dllimport) #endif typedef HRESULT (*AVECALLBACK) (PBYTE pbData, LONG lDataLength); #define E_DEVICE_NOT_READY 0xB0004001L class DEVICECONTROL_API AVEControl { public: HRESULT StartRecordWithoutPreview(HWND hWndCap, CString FileName, __int64 pFileLength, UINT pFileMessage, BOOL pShowSetting = TRUE); HRESULT StartRecordWithPreview(HWND hWndCap, RECT rc, CString FileName, __int64 pFileLength, UINT pFileMessage, BOOL pShowSetting = TRUE); HRESULT StartPreview(HWND hWndCap, RECT rc); HRESULT SetVideoClippingWindow(HWND hwnd); HRESULT SetCallback(AVECALLBACK Callback); HRESULT GetVideoStatus(PUCHAR pSta); HRESULT SetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect); void GetCurrentImage(CString BmpFileFullName); BOOL IsGraphRunning(void); HRESULT StopGraph(void); HRESULT ApplySettings(CString IniFileFullName); HRESULT SetVideoProcAmp(long Property, long Value); HRESULT GetVideoProcAmp(long Property, long* Value); HRESULT GetEvent(long* EventCode, LONG_PTR* Param1, LONG_PTR* Param2, long msTimeout); HRESULT SetNotifyWindow(OAHWND hwnd, long lMsg, LONG_PTR lInstanceData); HRESULT InitDeviceControl(void); AVEControl(); virtual ~AVEControl(); }; #endif // !defined(AFX_AVECONTROL_H__4E171B4B_A11B_49F1_B41C_5F4A31B5CF08__INCLUDED_)
dfbx
Posts
-
How to wrapper a MFC Dll , please help!!! -
How to use a class in an unmanged DLLI have a video capturer card SDK. in the .h file, defined a class all functions is in the class. so i want to know how can i use the function? because when i use the [Dllimport] to define the function in C#, when running, it doesn't work right,for an exception means "can not found the entrypoint in dll". so i wondered the reason is the define of Class in dll file. what can i do then? the .h file is shown as below: // AVEControl.h: interface for the AVEControl class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_AVECONTROL_H__4E171B4B_A11B_49F1_B41C_5F4A31B5CF08__INCLUDED_) #define AFX_AVECONTROL_H__4E171B4B_A11B_49F1_B41C_5F4A31B5CF08__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #ifdef DEVICECONTROL_EXPORTS #define DEVICECONTROL_API __declspec(dllexport) #else #define DEVICECONTROL_API __declspec(dllimport) #endif typedef HRESULT (*AVECALLBACK) (PBYTE pbData, LONG lDataLength); #define E_DEVICE_NOT_READY 0xB0004001L class DEVICECONTROL_API AVEControl { public: HRESULT StartRecordWithoutPreview(HWND hWndCap, CString FileName, __int64 pFileLength, UINT pFileMessage, BOOL pShowSetting = TRUE); HRESULT StartRecordWithPreview(HWND hWndCap, RECT rc, CString FileName, __int64 pFileLength, UINT pFileMessage, BOOL pShowSetting = TRUE); HRESULT StartPreview(HWND hWndCap, RECT rc); HRESULT SetVideoClippingWindow(HWND hwnd); HRESULT SetCallback(AVECALLBACK Callback); HRESULT GetVideoStatus(PUCHAR pSta); HRESULT SetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect); void GetCurrentImage(CString BmpFileFullName); BOOL IsGraphRunning(void); HRESULT StopGraph(void); HRESULT ApplySettings(CString IniFileFullName); HRESULT SetVideoProcAmp(long Property, long Value); HRESULT GetVideoProcAmp(long Property, long* Value); HRESULT GetEvent(long* EventCode, LONG_PTR* Param1, LONG_PTR* Param2, long msTimeout); HRESULT SetNotifyWindow(OAHWND hwnd, long lMsg, LONG_PTR lInstanceData); HRESULT InitDeviceControl(void); AVEControl(); virtual ~AVEControl(); }; #endif // !defined(AFX_AVECONTROL_H__4E171B4B_A11B_49F1_B41C_5F4A31B5CF08__INCLUDED_)
-
In C# ,How can i use a C++ DLL with a class being defined in head file.thank you for your answer. but I cann't do it. because the DLL is already exist. it was from a video capturer SDK. the head file is defined as in the article. and all functions have been defined in a class. if i use [DlImport],compile is right, but when i run, an exception shown with"can not found the entrypoint from .dll". i think the trouble is the class defination. so i want to know how to use the class from the dll.
-
In C# ,How can i use a C++ DLL with a class being defined in head file.the Question is not the data type. We can noticed that a class have been defined as below: { class DEVICECONTROL_API AVEControl } in the head file, all the functions is defined in the class. so if i use [DllImport] to define the function in C#, when run it, an exception is found ,which message as "EntryPoint can not be found in DLL", So I think the reason is that we cann't use the class from the unmanaged Dll directly in C#,we have to build a wrapper use C++.net . but How?
-
In C# ,How can i use a C++ DLL with a class being defined in head file.i have a .h file like below. how can i use it in C#? //--------------------------------------------------------------- // AVEControl.h: interface for the AVEControl class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_AVECONTROL_H__4E171B4B_A11B_49F1_B41C_5F4A31B5CF08__INCLUDED_) #define AFX_AVECONTROL_H__4E171B4B_A11B_49F1_B41C_5F4A31B5CF08__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #ifdef DEVICECONTROL_EXPORTS #define DEVICECONTROL_API __declspec(dllexport) #else #define DEVICECONTROL_API __declspec(dllimport) #endif typedef HRESULT (*AVECALLBACK) (PBYTE pbData, LONG lDataLength); #define E_DEVICE_NOT_READY 0xB0004001L class DEVICECONTROL_API AVEControl { public: HRESULT StartRecordWithoutPreview(HWND hWndCap, CString FileName, __int64 pFileLength, UINT pFileMessage, BOOL pShowSetting = TRUE); HRESULT StartRecordWithPreview(HWND hWndCap, RECT rc, CString FileName, __int64 pFileLength, UINT pFileMessage, BOOL pShowSetting = TRUE); HRESULT StartPreview(HWND hWndCap, RECT rc); HRESULT SetVideoClippingWindow(HWND hwnd); HRESULT SetCallback(AVECALLBACK Callback); HRESULT GetVideoStatus(PUCHAR pSta); HRESULT SetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect); void GetCurrentImage(CString BmpFileFullName); BOOL IsGraphRunning(void); HRESULT StopGraph(void); HRESULT ApplySettings(CString IniFileFullName); HRESULT SetVideoProcAmp(long Property, long Value); HRESULT GetVideoProcAmp(long Property, long* Value); HRESULT GetEvent(long* EventCode, LONG_PTR* Param1, LONG_PTR* Param2, long msTimeout); HRESULT SetNotifyWindow(OAHWND hwnd, long lMsg, LONG_PTR lInstanceData); HRESULT InitDeviceControl(void); AVEControl(); virtual ~AVEControl(); }; #endif // !defined(AFX_AVECONTROL_H__4E171B4B_A11B_49F1_B41C_5F4A31B5CF08__INCLUDED_)
-
How to define a function from WIN32 DLL in c# .i have the dllimport as below: [DllImport("DS40xxSDK.dll")] private static extern int SetOsdDisplayModeEx(IntPtr hChannelHandle,int color,bool Translucent,int param,int nLineCount,ushort[][] FormatArray); and call it as below: private void myFunc() { int number=OSDStrings.Length; ushort [] [] FormatArray=new ushort[number][]; for(int i=0;i
-
How to define a function from WIN32 DLL in c# .i want to use a function defined in a win32 dll. which is defined as below: void Func1(int a,int b,USHORT ** VarArray); in C#, which data type should i use for the parameter " USHORT ** VarArray "?
-
How to control muliti DVD Burner in same time.I want use one host and 8 Dvd Burners to burn 4 or 8 DVD-Rs with diffrent datas in same time. But the IMAPI can only control one Drive even the FoxBurner SDK. So what can i do?