在 c++ 中通过 shellexecute 运行 gbak.exe

发布于 2024-09-29 17:10:21 字数 271 浏览 1 评论 0原文

我想从我的 MFC 应用程序运行 gbak.exe 文件来备份 firebird DB, 我使用这个命令,但它不起作用:

shellexecute(hwnd,"open","gbak.exe"," -user HAMED -password 1234 DB2.FDB b.fbk","",SW_SHOW);

我的问题是关于 gbak 和 firebird。

大家可以帮助我吗? 谢谢

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","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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

赠佳期 2024-10-06 17:10:21

尝试使用 CreateProcess 代替,如下所示:

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);
}

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);
}
苦笑流年记忆 2024-10-06 17:10:21

gbak.exe 所在目录是否在您的系统路径中?如果没有,请将其放入系统 %PATH% 变量中,或者在调用 shellexecutecreateprocess 时指定完全限定的路径名​​。

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.

决绝 2024-10-06 17:10:21

更改“gbk.exe”,使其成为完整路径。例如:

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

此外,您将 gbak.exe 拼写为 gbk.exe

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

小嗲 2024-10-06 17:10:21

程序应断开与数据库的连接,然后放弃。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文