Link to home
Start Free TrialLog in
Avatar of MRTrevorF
MRTrevorFFlag for Canada

asked on

Exporting __stdcall Functions from VB.NET

I have been asked to write a DLL that exports functions through __stdcall.  I'd really like to do this using Visual Basic.NET (2010 currently) as that is my preferred programming environment.

I've spent quite a long time searching for samples on how to do this, but every hit I found was about the opposite direction - how to call __stdcall C/C++ functions within VB.NET

I'm writing a DLL that will be used by an existing piece of software and they have outlined a series of functions that I must 'export' from my DLL.  I've got sample code in C++, but, again, am hoping to make something in VB.NET.

In C++ the function looks like this:

LONG __stdcall XT_Init(DWORD nVersion, DWORD nFlags, HANDLE hMainWnd, void* lpReserved)

Open in new window


I need to know how to make an equivalent of this in VB.NET.

I've created a Class Library project and added a "COM Class" item to it.

I'm hoping this is posible but am apparently clueless.
Avatar of mrwad99
mrwad99
Flag of United Kingdom of Great Britain and Northern Ireland image

This is an interesting question.  

I did some research into this and the common consensus seems to be that this is not possible in VB.NET - there is no "__stdcall" equivalent.  I looked at http://bytes.com/topic/visual-basic-net/answers/564900-export-function-vb-net-dll (which you have probably also seen): this is just one example of many that form this consensus.

If you already have the C++ code I personally would not try and re-invent the wheel; build the C++ DLL and then call it from your VB.NET app.  (Once a DLL is built, nobody really cares what language it was written in as long as its functionality can be exposed.)  Your time would be best spent implementing your app.

There are enough people who know C++ on this site who can guide you through the DLL creation and any bugs that may arise in the function, so don't worry about that :)

HTH
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial