C語言登錄檔操作例項

2021-08-01 21:03:04 字數 1078 閱讀 5103

例子1:

#include

#include

int main(void)

else

char modlepath[256];

char syspath[256];

getmodulefilename(0,modlepath,256);//取得程式名字

getsystemdirectory(syspath,256);

ret=copyfile(modlepath,strcat(syspath,"\\hacker.exe"),1);

if(ret)

else printf("%s is exisis",modlepath);

return 0;

}例子2:

#include

#include

void 

main()

else 

regclosekey(hkey); 

else 

}

setregistrykey 這個函式功能是設定mfc程式的登錄檔訪問鍵,並把讀寫 ini檔案的成員函式對映到讀寫登錄檔。只要呼叫一下 setregistrykey並指定登錄檔鍵值,那麼下面6個成員函式,就被對映到進行登錄檔讀取了~

writeprofilebinary

writeprofileint

writeprofilestring

getprofilebinary

getprofileint

getprofilestring

msdn上面寫上面6個函式是寫到ini檔案的。所以俺就忽略了其訪問登錄檔的功能。無意中看了其mfc實現才有所了解。

例子如下:

cstring strusername,strpassword;

writeprofilestring("loginfo","password",strpassword);//同上~

strpassword = getprofilestring("loginfo","password");

C語言登錄檔操作例項

c語言登錄檔操作例項 例子1 include include int main void else char modlepath 256 char syspath 256 getmodulefilename 0,modlepath,256 取得程式名字 getsystemdirectory sysp...

登錄檔操作例項

using system using microsoft.win32 subpath software microsoft windows currentversion policies explorer string separatorchar char separator separatorch...

c 操作登錄檔

1.讀取指定名稱的登錄檔的值 private string getregistdata string name 以上是讀取的登錄檔中hkey local machine software目錄下的 目錄中名稱為name的登錄檔值 2.向登錄檔中寫資料 private void wtregedit st...