开发者

run gbak.exe by shellexecute in c++

开发者 https://www.devze.com 2023-01-23 03:21 出处:网络
I want to run gbak.exe file from my MFC application to backup firebird DB, i use this order but it didn\'t work:

I want to run gbak.exe file from my MFC application to backup firebird DB, i use this order but it didn't work:

shellexecute(hwnd,"open",开发者_StackOverflow中文版"gbak.exe"," -user HAMED -password 1234 DB2.FDB b.fbk","",SW_SHOW);

my problem is about gbak and firebird.

can every on help me? Thanks


Try to use CreateProcess instead, something like this:

STARTUPINFO si = { 0 };  
PROCESS_INFORMATION pi = { 0 };  

si.cb = sizeof(si); 

std::string sCommand = "gbak.exe -user HAMED -password 1234 DB2.FDB b.fbk"

BOOL bStart = ::CreateProcess(NULL,(LPSTR) sCommand.c_str(),NULL,NULL,FALSE,CREATE_NEW_CONSOLE | CREATE_DEFAULT_ERROR_MODE,NULL,NULL,&si,&pi);

if (bStart)
{
 // Wait 2 minutes or something for the process to complete
 ::WaitForSingleObject(pi.hProcess,1000*(2*60));
 CloseHandle( pi.hProcess );
 CloseHandle( pi.hThread );
}else
{
  DWORD dwLast = GetLastError();
  printf("Error %d",dwLast);
}


Is the directory where gbak.exe is located in in your system path? If not, put it into your systems %PATH% variable or specifiy a fully qualified path name when calling shellexecute or createprocess.


change "gbk.exe" so that it is a full path. Something like:

c:\Program Files\thunderbird\gbak.exe"

Also, you misspelled gbak.exe as gbk.exe


Program should disconnect from Data Base and then give back up.

0

精彩评论

暂无评论...
验证码 换一张
取 消