Thread: DLLs in c++

  1. #1
    Registered Viking
    Join Date
    Aug 2006
    Location
    Norway
    Posts
    19

    DLLs in c++

    in C#, you can import function from DLLs like this

    Code:
    [System.runtime.interopServices.DLLImport("win32.dll")]
    public extern int MessageBox(........);
    how do I do this in c++?

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    Win32API way is LoadLibrary. Which will still work with C++/CLI
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    Registered Viking
    Join Date
    Aug 2006
    Location
    Norway
    Posts
    19
    anywhere I can find a tutorial on how to do this?

  4. #4
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    LoadLibrary/GetProcAddress can be used to import things at run-time if that is what you want.

    DLL Main: http://msdn2.microsoft.com/en-us/library/1ez7dh12.aspx

    LoadLibrary/GetProcAddress:

    http://msdn.microsoft.com/library/de...oadlibrary.asp
    http://msdn.microsoft.com/library/de...rocaddress.asp

    http://msdn2.microsoft.com/en-us/library/zzk20sxw.aspx
    http://msdn2.microsoft.com/en-us/library/64tkc9y5.aspx

    Determining which method to use:

    http://msdn2.microsoft.com/en-us/library/253b8k2c.aspx

    Example code everywhere. You can search the internet, MSDN, newsgroups, this forum, etc.

  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    But actually you should just get the header and import library of the DLL from the vendor and use the functions directly.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Some doubts on DLLs
    By BrownB in forum Windows Programming
    Replies: 1
    Last Post: 05-30-2007, 02:25 AM
  2. standart dlls
    By keeper in forum C++ Programming
    Replies: 3
    Last Post: 07-05-2006, 07:32 PM
  3. Can't load string from resource DLL's string table
    By s_k in forum Windows Programming
    Replies: 4
    Last Post: 07-15-2003, 06:43 AM
  4. question about DLL's and class functions
    By btq in forum Windows Programming
    Replies: 2
    Last Post: 02-25-2003, 06:08 AM
  5. DLLs <- sound files, and nesting.
    By sean in forum C++ Programming
    Replies: 2
    Last Post: 10-28-2002, 05:13 PM