Workdir med Shell("c:\bla\program.exe")
Er det muligt at få et workdir når man bruger Shell ?Jeg skal køre Counter-Strike, og det går ikke så godt ..
Hvis jeg ikke har et working dir som c:\SIERRA\Half-Life\ så virker Counter Strike ikke .. så skriver den at custom game cstrike ikke er installeret hehe ..
ShellAndWait "c:\SIERRA\Half-Life\hl.exe -console -game cstrike", vbNormalFocus
Og selve ShellAndWait:
Private Sub ShellAndWait(ByVal program_name As String, _
ByVal window_style As VbAppWinStyle)
Dim process_id As Long
Dim process_handle As Long
On Error GoTo ShellError
process_id = Shell(program_name, window_style)
On Error GoTo 0
Me.Visible = False
DoEvents
process_handle = OpenProcess(SYNCHRONIZE, 0, process_id)
If process_handle <> 0 Then
WaitForSingleObject process_handle, INFINITE
CloseHandle process_handle
End If
Me.Visible = True
Exit Sub
ShellError:
MsgBox "Fejl: Kunne ikke starte - " & _
txtProgram.Text & vbCrLf & _
Err.Description, vbOKOnly Or vbExclamation, _
"Error"
End Sub
