WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

DllCall Information

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

VB Dll Usage with DllCall

Keywords: 	 DllCall Visual Basic DLL

Question:

I have created a .dll file with VB6 that has a few standard VB Public Functions. When I try to call them from Winbatch, I get an entry point error. Please HELP! I hear to VB dlls can be used from Winbatch.

Does someone know how to format the dll/functions or call them so that it works?

Answer:

What do the exported function names appear as in your VB6 DLL file?

Use the QUIKVIEW.EXE program to see what the exported functions (& their ordinal values) are.

Make sure that your DllCall() function call uses the EXACT name of the function as exported in the DLL (which is not necessarily the same as the function name in your source code).

Other than that, be very careful about passing mechanisms used to pass parameter values into the functions that are being called. Stick to passing by value instead of by reference. Passing by reference implies that your functions in the DLL are able to modify the value being passed in. The only way to support this with WinBatch is to use binary buffers and the 'lpbinary' data type in the DllCall() function call.

Simple data types can be returned by the function that is called. Complex record structures should be avoided.

If possible, re-write your DLL to be an OLE server and create methods that can be used to accept data and return results. When you are in full control of the code that you are writing you can make things much easier on yourself. WinBatch can work very nicely as an OLE client that can activate and talk to an OLE server. Of course, there are more setup activities involved in registering an OLE server on your system.

Question (cont'd):

I used quickview to look at the dll and no matter how many "public" functions that I create in the dll, there are only 4 listed (in quickview). None of the ones listed look anything like my functions. Is there something that I need to do before compiling the dll the export these functions? I know that making them public is enough if you are to be using the dll with other VB programs.

Answer:

I would recommend that you check out the MSDN knowledge base at http://msdn.microsoft.com and see what references you can find there. I do all of my DLL projects in Delphi and Visual C++. In those languages you declare the function as using the 'stdcall' calling convention and add on an 'export' keyword to the declaration of the function. You also have options with these languages to use a module definition (.DEF) file that the linker uses to assign the functions to certain ordinals.

I don't create my DLL's with VB but it should have a similar mechanism. I'm not sure that just defining the functions as public causes them to be exported.

There is also some kind of "Export" you have to do. Not sure. Check VB Newsgroups? http://www.deja.com ?? Search VB help files for Export.


Article ID:   W14220
Filename:   VB Dll Usage with DllCall.txt
File Created: 1999:10:26:11:22:28
Last Updated: 1999:10:26:11:22:28