Setting a working folder.

I've created an application the uses an external DLL. This DLL is currently in the same path as my VB project.
When I run the project trough VB it can't find this DLL. But when I run this project by double clicking on the *.vbp file, its O.K.
Does anyone know how to overcome this problem?!

In my project I wrote the following:
Declare Function MyFuncion Lib "MyDLL.dll"


yafitaAsked:
Who is Participating?
 
BobbyOwensCommented:
ChDir app.path
0
 
BobbyOwensCommented:
VB uses a different path wor it's working folder. Why don't you put the DLL in the Windows System path?
0
 
BobbyOwensCommented:
I've just checked. If you open VB via the EXE and then open the directory, the current directory is treated as where VB has been installed. If you double click a VBP, the current directory is that of the project.

You need to either always double click the VBP, or put the DLL in the VB path.

You could also try chaning the current directory to the App.path before calling the DLL
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
BobbyOwensCommented:
....Forgot to mention. Make sure the VBP is on the same drive as VB. If it isn't, you'll need to run:

ChDrive DriveLetter

before running

ChDir app.path
0
 
yafitaAuthor Commented:
How ca I change the current directory to App.path?
0
 
yafitaAuthor Commented:
How ca I change the current directory to App.path?
0
 
BobbyOwensCommented:
ChDir app.path
0
 
AzraSoundCommented:
why dont you just add a reference to this dll?
0
 
BobbyOwensCommented:
I thought you could only add references to COM dll's. This sounds like and API style DLL.
0
 
AzraSoundCommented:
yeah but since i dont know i gave a suggestion
also it strikes me funny he is having this problem so long as the more common dlls are in windows/system directory and are thus registered there. the program should automatically find it
0
 
yafitaAuthor Commented:
Thanks. It is fixed now.
And you're right. It is an API DLL (and I can't put it in the system library...).
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.