Results 1 to 5 of 5

Thread: making a dll [resolved]

  1. #1

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755

    Question making a dll [resolved]

    Hi

    i want to be able to make a dll that i can use from another program to send a couple of values to and make it return some values. how do i do this?
    i only know really basic c++ syntax...
    Last edited by cyborg; Jul 27th, 2003 at 02:09 PM.
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  2. #2

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    nm...found the answer
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  3. #3
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403
    main.cpp
    Code:
    #define WIN32_LEAN_AND_MEAN
    #include <windows.h>
    
    BOOL WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID pReserved)
    {
         return TRUE;
    }
    
    int WINAPI MyAddFunction(int a, int b)
    {
         return a + b;
    }
    
    int WINAPI MyXorFunction(int a, int b)
    {
         return a ^ b;
    }

    project.def
    Code:
    LIBRARY "My Project"
    EXPORTS
        MyAddFunction @1
        MyXorFunction @2

    note that I declared all the functions as WINAPI (__stdcall). If you don't, they default to _cdecl and you probably wont be able to use them from Visual Basic, if that's what you're trying to do.
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  4. #4
    Hyperactive Member
    Join Date
    Jan 2003
    Location
    The Netherlands
    Posts
    386
    Can you give me a way of doing it in plain C, without including the windows header file?

  5. #5
    Addicted Member Buy2easy.com's Avatar
    Join Date
    Jul 2002
    Posts
    200
    just wondering...is the code you posted all it takes to write a *.dll that will run in vb?

    i have a question for you...

    Say you wanted to write a function that would read a file a line at a time and then return the lines as an array of strings to be read in a vb program how would you need to return the variables.

    I guess my question is...How do you convert a C++ string which is just an array of characters into a vb string (i am guessing it is just an easier to use array of characters but i am not sure)

    Thanks ahead of time!

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