Calling C# Callbacks from C++ dll?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alag20
    New Member
    • Apr 2007
    • 84

    Calling C# Callbacks from C++ dll?

    Hi Guys,
    I have a C++ third party dll which does some algorithms for us and seldomly passes data back. Now we were wanting to use DLLIMPORT from c# to utilize these functions from C++ but are having some issues.

    Here are the function declaration in C++.

    Code:
    int DoWSUpdate(LPSTR lpName,LPSTR lpPath,LPSTR lpBinPath,MyCallBack pMyCallBack) 
    
    void (CALLBACK *MyCallBack)(DWORD dStatus,LPSTR Cur,long Complete,long AllComplete,LPSTR szDescript)
    To utilize the above i have written the following c# code.

    Code:
    public delegate void MyCallBack(int dStatus,  string Cur, long Complete, long AllComplete, string szDescript);
    
    [DllImport("CPLUS.dll", SetLastError = true, EntryPoint = "DoWSUpdate")]
    public static extern int DoWSUpdate([MarshalAs(UnmanagedType.LPStr)] string lpName, [MarshalAs(UnmanagedType.LPStr)] string lpPath, [MarshalAs(UnmanagedType.LPStr)] string lpBinPath, [MarshalAs(UnmanagedType.FunctionPtr)] MyCallBack pMyCallBack);
    Please advise what am i doing wrong here as each time i try to invoke DoWSUpdate i get

    Unable to find an entry point named 'DoWSUpdate' in DLL 'CPLUS.dll'.

    Please help guys.......
Working...