小小问题:如何使开机时自动运行本程序? 如题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 注册表位置HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run 自动运行的代码, 假设你的程序叫mfc.exevoid AutoRun(){ char CurrentPathName[MAX_PATH]; HKEY hNewKey; UINT RetVal; LPCSTR RgsKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Run"; ::GetModuleFileName(NULL, CurrentPathName, MAX_PATH); RetVal = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, RgsKey, 0, KEY_WRITE, &hNewKey); if(RetVal) { return; } RetVal = ::RegSetValueEx(hNewKey, "mfc", 0, REG_SZ, (const unsigned char *)CurrentPathName, MAX_PATH); if(RetVal) { RegCloseKey(hNewKey); return; }} VC线程中关闭串口 opencv中感兴趣区域相关问题求解 自绘ComboBox下拉条自动隐藏的问题 让CFormView被激活为当前窗口之后执行某段代码应该怎么做? 如何让两个窗口拖动时中间不分离 如何动态检测和设置本地(局域网)的防火墙设置啊?等待中... 如何用vc6.0创建一个com对象? 快疯了 如何让CListCtrl控件完全覆盖视图窗口? 如何利用POP3协议检测新邮件? 如何往资源中加入一个256色的图标 关于this指针
{
char CurrentPathName[MAX_PATH];
HKEY hNewKey;
UINT RetVal;
LPCSTR RgsKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Run"; ::GetModuleFileName(NULL, CurrentPathName, MAX_PATH);
RetVal = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, RgsKey, 0, KEY_WRITE, &hNewKey);
if(RetVal)
{
return;
}
RetVal = ::RegSetValueEx(hNewKey, "mfc", 0, REG_SZ, (const unsigned char *)CurrentPathName, MAX_PATH);
if(RetVal)
{
RegCloseKey(hNewKey);
return;
}}