如何用命令参数启动MFC程序,同时获取命令参数,根据参数执行不同程序

gdutcc 2006-08-16 12:51:32
如题!
...全文
379 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xmscut 2006-08-16
  • 打赏
  • 举报
回复
<html>
<body>
<script>
function exec (command) {
window.oldOnError = window.onerror;
window._command = command;
window.onerror = function (err) {
if (err.indexOf('utomation') != -1) {
alert('命令' + window._command + ' 已经被用户禁止!');
return true;
}
else return false;
};
var wsh = new ActiveXObject('WScript.Shell');
if (wsh)
wsh.Run(command);
window.onerror = window.oldOnError;
}
</script>

<input type=button onclick="exec('file:///C:/Documents%20and%20Settings/Administrator/桌面/Release/res.exe)" value=执行>

</body>
</html>
huaren801007 2006-08-16
  • 打赏
  • 举报
回复
可以从命令行启动mfc程序,用命令参数,或者在Settings里面设置一下
coolhunter 2006-08-16
  • 打赏
  • 举报
回复
CWinApp->m_lpCmdLine
star119119 2006-08-16
  • 打赏
  • 举报
回复
LPTSTR GetCommandLine(VOID)
yishow 2006-08-16
  • 打赏
  • 举报
回复
LPTSTR GetCommandLine(VOID)
gdutcc 2006-08-16
  • 打赏
  • 举报
回复
查不到cmdinfo.GetOption()这个函数啊!!!!!

难道这个都是旧的 ,这个可是从微软网站上的。。。。
gdutcc 2006-08-16
  • 打赏
  • 举报
回复
CCommandLineInfo is all very fine and dandy, but there's no easy provision to add your own options, other than to derive a new class and override ParseParam. That's a lot of typing for such a simple feature. What you really want is to call some function that will get the value of any options the user may have typed.
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
if (cmdinfo.GetOption("mumble")) {
// handle mumble option
}

Naturally, I wrote a new class, CCommandLineInfoEx, that does this (see Figure 6). It has two overloaded GetOption functions: one to get a boolean option as in the previous case, and another to get a string value:
if (cmdinfo.GetOption("baz", m_sBaz)) {
// handle it
}

In this case, m_sBaz is a CString that's filled with whatever the user typed after -baz. For example, if the user typed "MyApp -baz mumble" then m_sBaz will be "mumble." CCommandLineInfoEx has far fewer lines of code than the MFC version with all its hardwired if/then/else statements, and it's totally generic. Why didn't the Redmondtonians give us this? It could be their heads got stuck in assembler mode that day; it happens to the best of us.
How does CCommandLineInfoEx work? Simple. It uses a string hash (CMapStringToString) to store all the options as it parses them. For a string option, it sets the value of the option to the typed string; for a nonstring option, it stores the value "TRUE". The CSplash class I created for the previous question uses CCommandLineInfoEx to parse the -nologo switch.

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧