Results 1 to 4 of 4

Thread: VC++ DLL Call

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Okay, I've learned all of this in the wrong order. I learned C++ (or GNU C++ for those of you who care), then I dove into VB (like that was hard) and now someone has asked me to port a VB DLL to VC++.

    Now that's fun.

    Anyway... I've been poring through MSDN's web site all morning looking for one thing or another. My question now is... what is the syntax for calling a DLL from VC++.

    In VB I could do the following:

    Code:
    ' InternetSetStatusCallback
    Public Declare Function InternetSetStatusCallback Lib "wininet.dll" _
    (ByVal hInternet As Long, ByVal lpfnInternetCallback As Long) As Long
    
    Function DoWork
      InternetSetStatusCallback(lngVar, lngVar2)
    end function
    How do I do that in VC++.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Use LoadLibrary() and get a pointer to the function you want to call. I think that's how it's done. If it's a Windows API function then it should be useable already just by including windows.h.
    Harry.

    "From one thing, know ten thousand things."

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Often, when DLLs are supplied, you also get a header and an import library. To use them simply include the header and link with the library. You can then use all the functions as defined (this is how you use the API from VC++).

    If you only have the DLL and the function definitions then you have to go with Harry's method
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Thanks, guys. The header file works beautifully, Parksie.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

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