URL: https://www.overclockers.at/coding-stuff/vb-programm_starten_29630/page_1 - zur Vollversion wechseln!
Wie lautet in Visual Basic der Befehl, um ein Programm zu starten (also ich klick auf Button-> Programm startet)
Ach ja, wenn ich grad dabei bin: wie kann man auf Knopfdruck eine bestimmte Textdatei öffnen?
Entweder mit der Shell oder der AppActivate-Anweisung oder per API-Call.
Eine bestimmte Textdatei? Welche?
Zitat von JCEntweder mit der Shell oder der AppActivate-Anweisung oder per API-Call.
Eine bestimmte Textdatei? Welche?

beispiel für "in textdatei schreiben" - ist ein logging skript, das per aufruf eine zeile ins logfile hinzufügt.
Code: PHPPublic Sub Logging(strLogText) Dim fso As FileSystemObject Dim file As TextStream Dim dtFileDate As String Dim strFileName As String Dim strTime As String Set fso = New FileSystemObject strFileName = "mylogfile.txt" If (fso.FileExists(strFileName)) Then Set file = fso.OpenTextFile(strFileName, ForAppending) Else Set file = fso.CreateTextFile(strFileName, False) End If strTime = Format(Now(), "hh:mm:ss AMPM") file.WriteLine strTime & " // " & strLogText Set file = Nothing Set fso = Nothing End Sub

Hast die Hilfe wohl auch nicht installiert?
Ich hab hier's VB ned da, aber es dürfte in etwa so ablaufen:
shell Datei incl. Pfad as String, Parameter für Window-State (minimized, maximized, hidden, ...)
appactivate "titel der anwendung (steht in der titlebar)
Diese luschigen Funktionen benutze ich schon lange nicht mehr, da gibt's auch keine haftung für richtigkeit von meiner seite.
@rettich: danke, ist glaub ich etwas zu viel, dass du da geschrieben hast, aber danke, ich schaus mir mal an
@JC: Ich hab schon die Hilfe, aber ich wusste nicht genau, nach was ich suche, jetzt da ich weiß, dass ich nach shell suchen soll, hab ichs auch gefunden, danke
Zitat von rettichDim fso As FileSystemObject
Set fso = New FileSystemObject
If (fso.FileExists(strFileName)) Then
Set file = fso.OpenTextFile(strFileName, ForAppending)
End If
[/php]

Projekt -- Verweise, hinzufügen, fertig.
noch eine Frage: Wie kann ich erzwingen, dass das Programm immer im Vordergrund bleibt?
Also wenn ich auf Knöpfchen drücke, startet sich ein Programm, und das VB-Programm bleibt aber im Vordergrund
Du meinst, dass es immer im Vordergrund bleibt? So wie Winamp, bei drücken der Tasten Strg+A?
Only by API-Call.
Zitat von JCDu meinst, dass es immer im Vordergrund bleibt? So wie Winamp, bei drücken der Tasten Strg+A?
Only by API-Call.
*rofl*Zitat von jayjayJa, meine ich, wie mach ich das mit API-Call, was is so besonderes an API-Call, und wie verwend ich das
Code:Option Explicit Private Const SWP_NOMOVE = 2 Private Const SWP_NOSIZE = 1 Private Const HWND_TOPMOST = -1 Private Const HWND_NOTOPMOST = -2 Private Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE Private Declare Function SetWindowPos Lib "user32" _ (ByVal hWnd As Long, _ ByVal hWndInsertAfter As Long, _ ByVal x As Long, _ ByVal y As Long, _ ByVal cx As Long, _ ByVal cy As Long, _ ByVal wFlags As Long) As Long Public Function SetTopMostWindow(hWnd As Long, Topmost As Boolean) As Long ' Function sets a window as always on top, or turns this off ' hwnd - handle the the window to affect ' Topmost - do you want it always on top or not On Error GoTo ErrHandler If Topmost = True Then 'Make the window topmost SetTopMostWindow = SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS) Else SetTopMostWindow = SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS) 'SetTopMostWindow = SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, FLAGS) SetTopMostWindow = False End If Exit Function ErrHandler: Select Case Err.Number Case Else Err.Raise Err.Number, Err.Source & "+modAPIStuff/SetTopMostWindow", Err.Description End Select End Function Private Sub Form_Load() SetTopMostWindow Me.hWnd, True End Sub
overclockers.at v4.thecommunity
© all rights reserved by overclockers.at 2000-2026