FAQ (Frequently Asked Questions)
for Visual Basic 1.x-6.x developers on using WSQ image library





How to call and use WSQ image library functions from Visual Basic?

In Visual Basic it is not possible to directly call a C function in a DLL if that function uses the _cdecl calling convention. This is because Visual Basic uses the _stdcall calling convention for calling functions. This is a problem because if _cdecl is used, the calling function is responsible for cleaning up the stack. However, if _stdcall is used, the called function is responsible for cleaning up the stack.

The solution is to use wrapper DLL which wraps __cdecl calls into __stdcall calls.

Such a wrapper interface is provided in DLL file "WSQ_library_stdcall.dll"




When I'm trying to declare my function from the DLL, I've got Runtime Error 53: File not found ' WSQ_library_stdcall.dll'.
This only happens when I run my program in Visual Basic IDE.
If I MAKE the executable .EXE and run it outside VB IDE, everything works fine.

Visual Basic first looks for the DLL in the default folder - under the IDE which is not necessarily the same as the App.Path.

When compiled it does.

The standard trick is to do:

  
ChDir App.Path

before the first call into your DLL. You don't need it before every call into it, only the first, since that is what loads the DLL.

Also you need to ChDrive to the current application drive.

When your application is compiled, the DLL is always found in the first step, since your application now has its own "directory it was loaded from". The current directory no longer matters for loading the DLL.




Changing the directory in the CommonDialog changes some variable that VB uses so that it is no longer looking for my DLL in the application directory. What should I do?

Reset the current drive and folder with

  
ChDrive/ChDir

commands (using App.Path as arguments) or use

  
CommonDialog1.Flags = cdlOFNNoChangeDir




I am trying to debug a DLL I wrote in C and call from VB. Everything works fine if the VB program is an .EXE and everything works fine in the design environment the first time the functions in the DLL are run.
The problem occurs the second time the DLL is run in the design environment (even if I exit and restart the program).
Is there a way to tell VB to unload a DLL as run time and design time? (applies to: Visual Basic 4.x/5.x/6.x)

Loading and Unloading DLLs in the Design Environment
Microsoft Knowledge Base Article ID: 129514 Last Review: December 9, 2003 Revision: 2.0

SYMPTOMS

You may not be able to overwrite a dynamic-link library (DLL) after calling into it from Visual Basic in design time while the Visual Basic design environment is still running. This problem is generally encountered when users are developing DLLs for Visual Basic and are debugging their DLL code.

CAUSE

When a function within a DLL is called by a program in the design environment, the DLL is loaded into memory. When the program is stopped, the DLL is kept in memory and is only unloaded when the user exits the design environment or when a hard edit is performed on a Declare statement that references the DLL. This prevents Visual Basic from having to load and unload DLLs every time the user runs and stops the program at design time.

RESOLUTION

You can force Visual Basic to unload a DLL by performing a hard edit on the Declare statement of a function that is declared within the DLL. For example, you can do a hard edit on the Declare statement by just deleting the "r" in "Declare" and then typing it back in. This forces a recompile, which causes Visual Basic to unload the DLL.




Will it be easy to port my application from Visual Basic Classic (1.x-6.x) to Visual Basic .NET ?

While theoretically both VB Classic and VB.NET are from the same family, in practice VB.NET is not compatible with VB 6 - not really even close, so migration even of simple VB projects to .NET presents quite a challenge.

If you are writing new application you should consider using Visual Basic .NET from the beginning.

Microsoft's mainstream support for VB6 officially ended on March 31st, 2005. Now that this has occurred, it becomes increasingly more likely that future updates to Windows may break existing VB code. If you are concerned about this and/or are concerned about migration issues associated with bringing existing VB code to the .NET platform, please take a moment to read and sign the petition

http://classicvb.org/Petition

asking Microsoft to extend there COM based VB product line. The impetus behind the petition is the desire to give companies and individuals with substantial investments in existing VB code a path forward to the latest development platform without the current requirement for wholesale rewrites of existing code.







Copyright ©2024 Cognaxon. All rights reserved. Privacy