Hallo Experten!
Ich moechte mein Programm mit Parametern aufrufen.
Jedoch finde ich nichts das einer main(/*Argumente*/) aehnlich sieht.
Kann man der WinMain Argumente uebergeben?
System: BCB5 / WinNT4 / Win2000
Danke im Vorraus, Christof
Hallo Experten!
Ich moechte mein Programm mit Parametern aufrufen.
Jedoch finde ich nichts das einer main(/*Argumente*/) aehnlich sieht.
Kann man der WinMain Argumente uebergeben?
System: BCB5 / WinNT4 / Win2000
Danke im Vorraus, Christof
Hi
Ich moechte mein Programm mit Parametern aufrufen.
Jedoch finde ich nichts das einer main(/*Argumente*/) aehnlich
sieht.
das geht bei Konsolenprogrammen so:
int main(int argc, char* argv[]){}
wobei ‚argc‘ die Anzahl der Parameter ist, und argv[] der Zeiger auf das Stringarray (also der erste parameter ist unter argv[0] u.s.w.).
Kann man der WinMain Argumente uebergeben?
bei der winmain() ist der parameter ‚LPSTR lpCmdLine‘ für die Parameter zuständig. Leider ist das hier nicht so schön getrennt wie bei Konsolenanwendungen. Da wirst Du Dir wohl einen kleinen Parser selbst schreiben müssen.
grüsse Micha
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // pointer to command line
int nCmdShow // show state of window
);
lpCmdLine: Pointer to a null-terminated string specifying the command line for the application, excluding the program name. To retrieve the entire command line, use theGetCommandLine function.
hoffe das hilft, gruss tobias
Hilft wenig.
Ich will z.B. mein Programm mit einem Dateinamen starten:
bla.exe blubb.dat
oder ihm Optionen übergeben:
bla.exe blubb.dat -a-b-c
So dass ich Abläufe im Programm über diese Schalter steuern kann. (muss ich halt noch programmieren)
Gruss, Christof
[Bei dieser Antwort wurde das Vollzitat nachträglich automatisiert entfernt]
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // pointer to command line
int nCmdShow // show state of window
);lpCmdLine: Pointer to a null-terminated string specifying the
command line for the application, excluding the program name.
To retrieve the entire command line, use theGetCommandLine
function.
Hilft wenig.
Ich will z.B. mein Programm mit einem Dateinamen starten:
bla.exe blubb.datoder ihm Optionen übergeben:
bla.exe blubb.dat -a-b-c
Hallo Christof!
IMHO hilft Dir obiger Tipp durchaus: lpCmdLine enthält die Konkatenation der Strings aus argv von ANSI-C.
Beispiel:
Kommandozeile: „bla.exe blubb.dat“
lpCmdLine: „blubb.dat“
Kommandozeile: „bla.exe blubb.dat -a-b-c“
lpCmdLine: „blubb.dat -a-b-c“
CU
Markus
Beispiel:
Kommandozeile: „bla.exe blubb.dat“
lpCmdLine: „blubb.dat“Kommandozeile: „bla.exe blubb.dat -a-b-c“
lpCmdLine: „blubb.dat -a-b-c“CU
Markus
Ah, jetzt kapier ichs.
Danke, Christof