|
-
Nov 11th, 1999, 11:42 AM
#1
Thread Starter
New Member
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.
-
Nov 11th, 1999, 01:01 PM
#2
Addicted Member
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
-
Nov 12th, 1999, 11:57 PM
#3
Thread Starter
New Member
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?
-
Nov 13th, 1999, 01:45 AM
#4
Hyperactive Member
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
[email protected]
ICQ: 15743470
AIM: TomY10
PERL, JavaScript and VB Programmer
-
Nov 16th, 1999, 08:57 AM
#5
Thread Starter
New Member
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?
-
Nov 16th, 1999, 09:57 AM
#6
Hyperactive Member
When Command1 is clicked, Text1.Text will become the path to MSPaint:
Module Code:
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:
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
[email protected]
ICQ: 15743470 Add Me ICQ Me
AIM: TomY10
PERL, JavaScript and VB Programmer
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
|