PDA

Click to See Complete Forum and Search --> : IS IT EVEN POSSIBLE???


Dec 11th, 2000, 03:11 AM
I have a C program with a function that I would like to be able to call from Visual Basic. I am guessing the way to do this would be to make a DLL with MS Visual C++ (which I have), but I haven't the faintest clue as how to go about doing this. What would be the simplest, easiest, and quickest way to accomplish my objective?

Vlatko
Dec 11th, 2000, 08:34 AM
Go to new Win32 Dll Project and put this in the code section:

void _stdcall Msg(HWND handle)
{
MessageBox(handle,"SomeText","Message",MB_OK);
}


Create a .def file in your project which contains:

LIBRARY "dllname.dll"
EXPORTS
Msg 1


This function displays a message box. To call it from VB use this:

Private Declare Sub Msg Lib "dllname.dll" (ByVal handle As Long)

Private Sub Command1_Click()
Msg Form1.hWnd
End Sub


[Edited by Vlatko on 12-11-2000 at 09:38 AM]