Results 1 to 3 of 3

Thread: convert C# code to call DLL into C++ code

  1. #1

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    convert C# code to call DLL into C++ code

    Not sure if this is in the correct place, since it's to do with C# and C++

    I've got the following code:
    Code:
    [DllImport("camdll.dll")]
    static extern void TiltCam (Int32 id, Int32 x, Int32 y);
    I've also got a dll file.


    I want to call this function in the dll file, but in a C++ application.

    What i've got so far is this:

    Code:
    HMODULE hDll = LoadLibrary("camdll.dll");
    FARPROC fpMoveCam = GetProcAddress(hDll, "TiltCam");
    typedef void(__stdcall *fpMoveCamT)(INT32 id,INT32 x, INT32 y);
    fpMoveCamT MoveCam = (fpMoveCamT)fpMoveCam;
    //////////////////////////////////////////
    MoveCam(1,500,500);
    Is this a correct translation?

    The reason that i ask is that it appears that i can call the function ok, but i sometimes get wierd errors, depending on the arguments, plus it doesn't do what its supposed to do.

    Thanks a lot for any help, even if it's to say that there must be something else wrong, i'm really stuck with this one.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  2. #2
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622

    Re: convert C# code to call DLL into C++ code

    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  3. #3

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: convert C# code to call DLL into C++ code

    Thanks for the link. I've since managed to get it working, turns out something else was wrong, causing the function to appear not to work.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width