|
-
Apr 18th, 2001, 05:20 AM
#1
I want to know on which location my application is running and I don't want to use application.path , i want is there any API that can tell the location ?
-
Apr 18th, 2001, 07:20 AM
#2
Here is some code try it out
Private Declare Function GetCurrentDirectory Lib "kernel32" Alias "GetCurrentDirectoryA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Sub Form_Paint()
Dim sSave As String
'create a buffer
sSave = String(255, 0)
'retrieve the current directory
GetCurrentDirectory 255, sSave
MsgBox sSave
End Sub
-
Apr 18th, 2001, 08:43 AM
#3
Frenzied Member
What's with the Form_Paint()
event.
-
Apr 19th, 2001, 07:50 AM
#4
Not important!
Thats just an example.
You can also take use of "form_load" or " command1_click" instead of "form_paint".
-
Apr 19th, 2001, 03:03 PM
#5
Originally posted by manishmenghani
I want to know on which location my application is running and I don't want to use application.path , i want is there any API that can tell the location ?
What's wrong with App.Path??
-
Apr 19th, 2001, 05:15 PM
#6
Using GetCurrentDirectory is not the same as using App.Path.
App.Path always returns the directory your exe is located in.
The GetCurrentDirectory API will return the current directory for the program.
If you make a shortcut to your exe file and set the "Start in" directory to be something other than the directory your program is in, App.Path and GetCurrentDirectory will have different results when you run your program from the shortcut.
By the way, you can use the CurDir function. It will do the same thing as the GetCurrentDirectory API. You might want to do that anyway, because He-M@n forgot to include code to get rid of the nulls at the end of the string returned by GetCurrentDirectory.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|