如题

解决方案 »

  1.   

    注册表位置HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
      

  2.   

    自动运行的代码, 假设你的程序叫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;
    }}