WCM - Das österreichische Computer Magazin Forenübersicht
 

Zurück   WCM Forum > Rat & Tat > Programmierung

Programmierung Rat & Tat für Programmierer

Microsoft KARRIERECAMPUS

 
 
Themen-Optionen Ansicht
Alt 27.11.2003, 13:43   #1
Sonic
Master
 
Registriert seit: 28.03.2000
Alter: 45
Beiträge: 691


Sonic eine Nachricht über ICQ schicken
Unglücklich Problem mit CreateProcess (C/Win32-API)

Hallo!

Ich hab ein Win32 Consolen Programm geschrieben das als Scheduled Task laufen soll und, unter anderem, automatisch Zip files mit hilfe eines externen packprogramms erstellt.

Das ganze funktioniert, wenn ich das Programm auf der Console starte, wunderbar.
Jedoch wenn es als Scheduled Task startet bekomme ich beim CreateProcess eine Windows Fehlermeldung (Messagebox) mit folgender Fehlermeldung:

"The Application failed to initzialize properly.
Click OK to terminate the aplication."

Ich hab im Moment leider keine Ahnung woran es liegen könnte und hoffe das jemand von euch rat weiß!

Wäre für jeden Rat dankbar!

Code zum Zippen:
PHP-Code:

/*** Function CompressFile ***\
exepath        Path of the zip executable
source        source directory where the file to be compressed lies
dest            destination path where compressed file will be put
name            source filename
password    password for encryption
returns 999 if the process could not be created or the returncode of the zip programm
*/

#define ZIP_COMPRESS_FORMAT "%s -add -lev=9 -silent -move -pass=%s \"%s%s.zip\" \"%s%s\""
#define ZIP_COMPRESS_FORMAT_LEN 56

int CompressFile(char *exepath,char sourcechar *destchar *namechar *password)
{
    
STARTUPINFO sti;
    
PROCESS_INFORMATION pri;
    
char *cmdline;
    
DWORD exitcode;

    
//Assemble Commandline
    
cmdline=(char*)malloc(sizeof(char)*(ZIP_COMPRESS_FORMAT_LEN+1+strlen(exepath)+strlen(source)+strlen(dest)+strlen(password)+strlen(name)*2));
    
sprintf(cmdline,ZIP_COMPRESS_FORMAT,exepath,password,dest,name,source,name);

    
memset(&sti,0,sizeof(STARTUPINFO)); 
    
sti.cb=sizeof(STARTUPINFO);
    
sti.lpDesktop="";

    if (
CreateProcess(NULLcmdline,NULLNULL0NORMAL_PRIORITY_CLASSNULLNULL, &sti, &pri))
    {
        
//Wait till process has finished
        
WaitForSingleObjectpri.hProcessINFINITE );
        
//And save the exitcode to be returned
        
GetExitCodeProcess(pri.hProcess, &exitcode);
        
        
//Cleanup
        
CloseHandlepri.hProcess );
        
CloseHandlepri.hThread );
        
free(cmdline);
        return 
exitcode;
    }
    else
    {
        
//The process could not be created
        
free(cmdline);
        return 
999;
    }

LG
____________________________________
__________________
|»»»»»SONIC««««««|
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Sonic ist offline   Mit Zitat antworten
 


Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
 

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.

Gehe zu


Alle Zeitangaben in WEZ +2. Es ist jetzt 10:07 Uhr.


Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Forum SEO by Zoints
© 2009 FSL Verlag