将这个bool型变量保存在外部,如文件、数据库或注册表中,程序刚开始时读取这个变量并判断,如果true,调另一程序(假设此程序名为C:\Test.exe),在CreateProcess函数中lpCommandLine参数为"C:\\Test.exe true",如果false,就是"C:\\Test.exe false",然后在Test.exe的源代码中,在弹出登录界面之前的适当位置,加入以下代码
// 获取命令行参数,就是获取.exe 后面的字符串
CString str = ::GetCommandLine();
int nFind = str.Find(".exe", 0);
nFind += 6;
str = str.Right( str.GetLength() - nFind );
if(str == "true")
{
// 将用户名设为10000,密码设为10000
// 然后跳过登录界面直接,直接显示主界面
else
{
// 弹出登录界面
}