stweelman
Nov 11th, 1999, 10:42 AM
My program needs to start another prograr to do some editing, but I belive that I need to get the path first this will need to be done programaticly dose anybody know how to do this? The file that will be edited will be installed with my program. I tryed
Shell("Appname.exe" & app.path & "file.xyz",1)
code sample please.
Keiko
Nov 11th, 1999, 12:01 PM
Hi stweelman,
You may try this ...
Dim myPath As String
myPath = IIf(Right(App.Path, 1) = "\", App.Path, App.Path & "\")
Call Shell(myPath & "Appname.exe " & myPath & "file.xyz", 1)
Does it help ?
Regards
stweelman
Nov 12th, 1999, 10:57 PM
No, unless I've made a mistake. What I need to do is the same as the find in windows start menu and I need to do it on mycomputer.
I'm looking for MSPaint.exe. I then need to shell MyPath & "MSPaint.exe C:\picture.bmp",1
I need to find MyPath programaticly?
Compwiz
Nov 13th, 1999, 12:45 AM
To find MSPaint.exe programically, open the registry and the default data under HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\MSPAINT.EXE
Then Shell that.
------------------
Tom Young, 14 Year Old
tyoung@stny.rr.com
ICQ: 15743470
AIM: TomY10
PERL, JavaScript and VB Programmer
stweelman
Nov 16th, 1999, 07:57 AM
OK, but how? I don't know how to work with the registry yet. I know that you use getsettings but what part is the key and so on?
Compwiz
Nov 16th, 1999, 08:57 AM
When Command1 is clicked, Text1.Text will become the path to MSPaint:
Module Code:
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const REG_SZ = 1 ' Unicode nul terminated string
Public Const ERROR_SUCCESS = 0&
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Public Function GetSettingString(hKey As Long, strPath As String, strValue As String, Optional Default As String, Optional Test As Boolean) As String
Dim hCurKey As Long
Dim lResult As Long
Dim lValueType As Long
Dim strBuffer As String
Dim lDataBufferSize As Long
Dim intZeroPos As Integer
Dim lRegResult As Long
' Set up default value
If Not IsEmpty(Default) Then
GetSettingString = Default
Else
GetSettingString = ""
End If
lRegResult = RegOpenKey(hKey, strPath, hCurKey)
lRegResult = RegQueryValueEx(hCurKey, strValue, 0&, lValueType, ByVal 0&, lDataBufferSize)
If lRegResult = ERROR_SUCCESS Then
If lValueType = REG_SZ Then
strBuffer = String(lDataBufferSize, " ")
lResult = RegQueryValueEx(hCurKey, strValue, 0&, 0&, ByVal strBuffer, lDataBufferSize)
intZeroPos = InStr(strBuffer, Chr$(0))
If intZeroPos > 0 Then
GetSettingString = Left$(strBuffer, intZeroPos - 1)
Else
GetSettingString = strBuffer
End If
End If
Else
If Test = True Then
GetSettingString = "-1"
End If
' there is a problem
End If
lRegResult = RegCloseKey(hCurKey)
End Function
Public Function GetMSPAINTPath() As String
If GetSettingString(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\App Paths\MSPAINT.EXE", "", , True) = "-1" Then
Err.Raise vbObjectError + 513, "Get MSPAINT Path", "MSPAINT IS NOT INSTALLED ON THIS SYSTEM!"
Exit Function
Else
GetMSPAINTPath = GetSettingString(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\App Paths\MSPAINT.EXE", "")
End If
End Function
Form Code:
Private Sub Command1_Click()
On Error GoTo NotFound
Text1.Text = GetMSPAINTPath
Exit Sub
NotFound:
MsgBox Err.Description, vbCritical, Err.Source
End Sub
Hope this helps.
------------------
Tom Young, 14 Year Old
tyoung@stny.rr.com
ICQ: 15743470 (http://wwp.icq.com/15743470) Add Me (http://wwp.icq.com/scripts/search.dll?to=15743470) ICQ Me (http://wwp.icq.com/scripts/contact.dll?msgto=15743470)
AIM: TomY10 (http://www.aol.com/aim/aim30.html)
PERL, JavaScript and VB Programmer