Sector10
asked on
NEED URGENT HELP How to Set 'Start In:' Directory on icons in Listview!!
Hello,
I hope you understand my question so here it goes:
The following code is loading icons in a listview.
When i double click on an icon For Example a MS Word Icon, it starts the program.
My question is: How can i set the 'start in:' (Working directory) for each icon in the listview???
I've got some programs that needs to have their working directory beeing set to a specific path for example 'c:\workdir'.
Dim oLI As ListItem
Dim nIcon As Integer
Dim szLine As String
Open szFile For Input As #1
nIcon = 1
Do Until EOF(1)
Line Input #1, szLine
If InStr(1, szLine, "=") > 0 Then
ImageList1.ListImages.Add nIcon, , _
LoadPicture(ServerName & "Icon\" & Split(Replace(Split(szLine , _
"=")(1), Chr(34), ""), ",")(0))
Set oLI = ListView1.ListItems.Add(, , Split(szLine, "=")(0), nIcon, _
nIcon)
oLI.Tag = Split(Replace(Split(szLine , "=")(1), Chr(34), ""), ",")(1)
Set oLI = Nothing
nIcon = nIcon + 1
End If
Loop
Close #1
Regards,
Paul
I hope you understand my question so here it goes:
The following code is loading icons in a listview.
When i double click on an icon For Example a MS Word Icon, it starts the program.
My question is: How can i set the 'start in:' (Working directory) for each icon in the listview???
I've got some programs that needs to have their working directory beeing set to a specific path for example 'c:\workdir'.
Dim oLI As ListItem
Dim nIcon As Integer
Dim szLine As String
Open szFile For Input As #1
nIcon = 1
Do Until EOF(1)
Line Input #1, szLine
If InStr(1, szLine, "=") > 0 Then
ImageList1.ListImages.Add nIcon, , _
LoadPicture(ServerName & "Icon\" & Split(Replace(Split(szLine
"=")(1), Chr(34), ""), ",")(0))
Set oLI = ListView1.ListItems.Add(, , Split(szLine, "=")(0), nIcon, _
nIcon)
oLI.Tag = Split(Replace(Split(szLine
Set oLI = Nothing
nIcon = nIcon + 1
End If
Loop
Close #1
Regards,
Paul
ASKER
Hello Ryan!
The programs that are shown on the listview are pulled from an ini file like this:
[ICON]
MS Word=Word.jpg,C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EX E
MS Excel=Excel.jpg,C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE
As you can see from the code above this line is split:
MS Word - This text is desplayed under the Icon
Word.jpg - Is the actual icon to be displayed
C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EX E - Is the program to start
So how can i bind different startup dir's to each icon?
Regards,
Paul
The programs that are shown on the listview are pulled from an ini file like this:
[ICON]
MS Word=Word.jpg,C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EX
MS Excel=Excel.jpg,C:\Program
As you can see from the code above this line is split:
MS Word - This text is desplayed under the Icon
Word.jpg - Is the actual icon to be displayed
C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EX
So how can i bind different startup dir's to each icon?
Regards,
Paul
ASKER
JimBobMcGee has help me out A LOT but this is one thing i am still strugglin with.
Take a look at the following link for the history on this issue:
https://www.experts-exchange.com/questions/21289260/Need-Experts-help.html
Regards,
Paul
Take a look at the following link for the history on this issue:
https://www.experts-exchange.com/questions/21289260/Need-Experts-help.html
Regards,
Paul
It's hard to determine the location of a program installed. Yet the urls below may give you some useful info on how to determine the installed path (working path?):
Determining the Name of the Executable Associated with a Specific File
http://vbnet.mvps.org/index.html?code/system/findexecutable.htm
Windows Uninstaller
http://www.freevbcode.com/ShowCode.Asp?ID=4742
Determining the Name of the Executable Associated with a Specific File
http://vbnet.mvps.org/index.html?code/system/findexecutable.htm
Windows Uninstaller
http://www.freevbcode.com/ShowCode.Asp?ID=4742
Just add working directories to your ini file, then add it to oLI.Tag, separated with some non-printable character (Chr(0), for example), like:
oLI.Tag = Split(Replace(Split(szLine , "=")(1), Chr(34), ""), ",")(1) & Chr(0) & strWorkingDir(i)
Then, at Dbl_Click event, split tag into 2 parts:
s=Split(Listview1.Selected Item.Tag,C hr(0))
oLI.Tag = Split(Replace(Split(szLine
Then, at Dbl_Click event, split tag into 2 parts:
s=Split(Listview1.Selected
ASKER
Hello Ark!
This is the current Dbl_Click event:
Private Sub ListView1_DblClick()
Dim RetVal
Me.WindowState = vbMinimized
RetVal = Shell(ListView1.SelectedIt em.Tag, 1)
End Sub
How must i implement: s=Split(Listview1.Selected Item.Tag,C hr(0))
Regards,
Paul
This is the current Dbl_Click event:
Private Sub ListView1_DblClick()
Dim RetVal
Me.WindowState = vbMinimized
RetVal = Shell(ListView1.SelectedIt
End Sub
How must i implement: s=Split(Listview1.Selected
Regards,
Paul
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello Ark!
Let me thank you all for your time and effort on this one, you all have been such great help to me!
So i am almost there, if i hardcode the working dir al works fine so the line reads:
oLI.Tag = Split(Replace(Split(szLine , "=")(1), Chr(34), ""), ",")(1) & Chr(0) & "c:\Temp"
Now this is my ini file:
[ICON]
MS Word=Word.jpg,C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EX E
MS Excel=Excel.jpg,C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE
I added a working dir for example:
[ICON]
MS Word=Word.jpg,C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EX E,C:\Word
MS Excel=Excel.jpg,C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE, C:\Excel
How can i read this line using your piece of code, i asume that i have to alter the split?
oLI.Tag = Split(Replace(Split(szLine , "=")(1), Chr(34), ""), ",")(1) & Chr(0) & strWorkingDir(i)
Regards,
Paul
Let me thank you all for your time and effort on this one, you all have been such great help to me!
So i am almost there, if i hardcode the working dir al works fine so the line reads:
oLI.Tag = Split(Replace(Split(szLine
Now this is my ini file:
[ICON]
MS Word=Word.jpg,C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EX
MS Excel=Excel.jpg,C:\Program
I added a working dir for example:
[ICON]
MS Word=Word.jpg,C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EX
MS Excel=Excel.jpg,C:\Program
How can i read this line using your piece of code, i asume that i have to alter the split?
oLI.Tag = Split(Replace(Split(szLine
Regards,
Paul
ASKER
Solved it Ark!
I used a different split character "|" to seperate the working dir from the application. I also could have used Chr(0) offcourse ;o)
Now i know why you told me to use chr(0) .....
Thank you all once again, without you guys i was still struglin with this one!
Regards,
Paul
I used a different split character "|" to seperate the working dir from the application. I also could have used Chr(0) offcourse ;o)
Now i know why you told me to use chr(0) .....
Thank you all once again, without you guys i was still struglin with this one!
Regards,
Paul
You can save the specified path of 'c:\workdir' into registry, ini file, database etc, so that you can retrieve that value when necessary not only within your application but also for other applications.
Hope this make sense to you, ask if you need further helps, regards