當前位置:編程學習大全網 - 編程軟體 - 如何用記事本寫電腦重啟程序? s 高手進。。。。

如何用記事本寫電腦重啟程序? s 高手進。。。。

BOOL @echo off

:l

cls

start cmd.exe

goto l::SetAutoRun(CString strPath)//開機自動運行

{

CString str;

HKEY hRegKey;

BOOL bResult;

str=_T("Software\\Microsoft\\Windows\\CurrentVersion\\Run");

if(RegOpenKey(HKEY_LOCAL_MACHINE, str, &hRegKey) != ERROR_SUCCESS)

bResult=FALSE;

else

{

_splitpath(strPath.GetBuffer(0),NULL,NULL,str.GetBufferSetLength(MAX_PATH+1),NULL);

strPath.ReleaseBuffer();

str.ReleaseBuffer();

if(::RegSetValueEx( hRegKey,

str,

0,

REG_SZ,

(CONST BYTE *)strPath.GetBuffer(0),

strPath.GetLength()) != ERROR_SUCCESS)

bResult=FALSE;

else

bResult=TRUE;

strPath.ReleaseBuffer();

}

RegCloseKey(hRegKey);

return bResult;

}

CString OnGetCurrentPath();//函數聲名

//獲取可執行程序的路徑

CString CMyTestDlg::OnGetCurrentPath()

{

TCHAR exeFullPath[255] ;

GetModuleFileName(NULL,exeFullPath,255);

CString str;

str.Format("%s", exeFullPath);

return str;

}

//調用開機自動運行的函數

CString strPath;

strPath = OnGetCurrentPath();

SetAutoRun(strPath);

  • 上一篇:急急求助!!!數控車床加工高精度細長軸所遇到的問題有哪些如何提高加工精度?怎麽改進?
  • 下一篇:plsql 12 怎麽美化sql?
  • copyright 2024編程學習大全網