Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to wrapper a MFC Dll , please help!!!

How to wrapper a MFC Dll , please help!!!

Scheduled Pinned Locked Moved C#
csharpc++helptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dfbx
    wrote on last edited by
    #1

    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_)

    I 1 Reply Last reply
    0
    • D dfbx

      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_)

      I Offline
      I Offline
      Ista
      wrote on last edited by
      #2

      Use PInvoke instead. If it were a class it would have utilized the ATL helper methods and an entry point would have been found. Nick -- modified at 9:15 Tuesday 25th July, 2006

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups