-
Question about the OpenLocation function
Is is possible to make the OpenLocation function accept a string variable as an argument? I tried, and I can't make it work. I am using VB6.
-
What is the OpenLocation function? I am not familiar with it.
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
It's a function used for opening a file with its default program (or just opening a program) and it takes a string containing the path to the file/program as an argument. Here is the code for it:
Code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Function OpenLocation(ByVal WhichFilePath As String, Optional sParams As String = "", Optional sStartIn As String = vbNullString, Optional lngOpenMode As Long = 1) As Long
OpenLocation = ShellExecute(0, "Open", WhichFilePath, sParams, sStartIn, lngOpenMode)
End Function
Last edited by Littlebro; 12-22-2008 at 02:54 AM.
-
OK, the first argument (WhichFilePath) accepts a string. You should be able to pass a string variable. How are you calling the function?
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
I call it like this:
OpenLocation ("C:\WINDOWS\system32\sol.exe") if I want to open a file or program in a specific location. I am using this function in conjunction with another function which gets a file path from a .ini file, and stores the path in a string variable. I know that this function works, but when I try to use the string variable as an argument for the OpenLocation function, it just opens the folder the program is in.
-
Sounds like the variable you're passing only contains a path, not the name of the actual program. Check the value of the variable you're passing to the function.
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
 Originally Posted by Littlebro
I call it like this:
OpenLocation ("C:\WINDOWS\system32\sol.exe") if I want to open a file or program in a specific location. I am using this function in conjunction with another function which gets a file path from a .ini file, and stores the path in a string variable. I know that this function works, but when I try to use the string variable as an argument for the OpenLocation function, it just opens the folder the program is in.
isnt that the way its supposed to be ? to open the folder where the file (executable or not) is in, afterall thats why its called OpenLocation, right ? 
cheers and seasons greetings to all !!!
BASED FROM YOUR POSTS, I HAVE EXAMINED YOUR BEHAVIORAL PATTERN AND I SAW YOUR BRAIN'S TWO SIDES : LEFT & RIGHT, AND I SAW THAT ON THE LEFT SIDE THERE'S NOTHING RIGHT WHILE ON THE RIGHT SIDE THERE'S NOTHING LEFT
-
The path obtained from the .ini file contains the name of the program I want to open. It doesn't open.
EDIT: I might have misphrased something above. The program doing the calling opens the folder it's in when I call OpenLocation using a string variable (with a value obtained from a .ini file) as an argument.
Last edited by Littlebro; 12-22-2008 at 03:48 AM.
-
If you hard code the path and file name does it work?
(i.e., OpenLocation ("C:\WINDOWS\system32\sol.exe") )
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
What prints in the debug window if you set a breakpoint on the call to OpenLocation and Debug.Print VariableName (replacing VariableName with the name of your string variable)?
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
I don't really know how to do what you are asking, but I have found a workaround. I set the caption of a label to the string, used the label caption as an argument, and it worked.
-
He is referring to using the debug window (or "immediate window") as a debugging tool to see what is actually in the variable.
This sort of thing is invaluable when working with code (and it doesn't even have to be troublesome code)
http://msdn.microsoft.com/en-us/libr...ffice.10).aspx
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
Nothing is printed in the debug window. The cursor just goes to the next line in the debug window.
EDIT: I feel like an idiot. The reason it wasn't working was that I declared the string variable in a private subroutine. Thanks for your help anyway.
Last edited by Littlebro; 12-24-2008 at 04:24 AM.
-
 Originally Posted by Littlebro
EDIT: I feel like an idiot. The reason it wasn't working was that I declared the string variable in a private subroutine. Thanks for your help anyway.
Don't feel like an idiot. Everyone has done the same thing, and I would venture to say, everyone has done the same thing more than once.
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
Similar Threads
-
Replies: 4
Last Post: 08-28-2005, 04:16 PM
-
By swapnil_paranja in forum C++
Replies: 20
Last Post: 08-25-2005, 03:54 PM
-
By MikeKraken in forum Database
Replies: 11
Last Post: 03-15-2005, 08:12 PM
-
Replies: 1
Last Post: 11-27-2001, 06:53 AM
-
By Chandra in forum VB Classic
Replies: 0
Last Post: 06-22-2000, 07:30 AM
Tags for this Thread
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks