VC登錄檔寫入和讀取字串

2021-08-02 00:16:27 字數 867 閱讀 3435

關於登錄檔讀寫的文章網上有很多,但是真的要用到的時候發現很難找到直接向登錄檔讀寫cstring字串的文章

void ctestdlg::wirtereg(void)

//寫入登錄檔 //型別 //名稱 //字元個數

//只能寫入乙個value

if (error_success != regsetvalue(hkey,nullptr,reg_sz,text("test"),4))

if (hkey ==nullptr)

long lret = 0;

lpstr lppath = (lpstr)(lpctstr)strr1;

//這個函式可以寫入更多的value //名稱 //強制為零 //型別 //資料

if (error_success != (lret = regsetvalueex(hkey, text(strr), 0, reg_sz, (const byte *)lppath, strr1.getlength())))

afxmessagebox(text("寫入登錄檔成功!"));

regclosekey(hkey);

}

void ctestdlg::readreg(void)

afxmessagebox(text("讀取登錄檔成功!"));

cstring s;

s.format(data);

sscanf(s,"%i,%i",&cc,&xx);

afxmessagebox(s);

}

C 讀取字串

我們在使用鍵盤輸入字串的時候,輸入流對於字串的讀取有幾種不同的實現方式。cin cin 在讀取字串時使用空白 空格 製表符和換行符 來確定字串的結束位置,這說明cin在獲取字元陣列輸入時只能讀取乙個單詞。而讀取該單詞後,cin將該字串放到陣列中,並在結果自動新增空字元。so,在某些時候,我們需要使用...

讀取字串長度

c 關於讀取乙個字串長度 包括空格回車 自用 方法1 include include using namespace std intmain 方法2 include include include include include using namespace std intmain 方法3 inc...

Qt QSettings讀取登錄檔和ini

1.讀取登錄檔,以讀取已經安裝的軟體為例。已經安裝的軟體資訊的登錄檔位置 hkey local machine software microsoft windows currentversion uninstall void widget initsoftwarelist reg.endgroup ...