載點:
https://docs.google.com/uc?id=0B4PwTcFHZPWbMDYwOGMzYTctZjdhYi00NDY4LWE2NGEtMGZhNjAyZmY3Zjgw&export=download&hl=zh_TW
程式畫面:
關鍵程序碼:
if(FileExists(sIniFile))
{
lRet = GetPrivateProfileString("People", "number", "0", sItemCount, sizeof(sItemCount), sIniFile);
peoplecount=StrToInt(sItemCount);
for(int i=0;i<peoplecount;i++)
{
lRet = GetPrivateProfileString("Name", IntToStr(i+1).c_str(), "0", sItemCount, sizeof(sItemCount), sIniFile);
name[i]=sItemCount;
lRet = GetPrivateProfileString("Phone", IntToStr(i+1).c_str(), "0", sItemCount, sizeof(sItemCount), sIniFile);
number[i]=sItemCount;
}
tot=peoplecount;
}
if(FileExists(sIniFile))
{
WritePrivateProfileString("People","number",IntToStr(tot).c_str(), sIniFile);
for(int i=0;i<tot;i++)
{
WritePrivateProfileString ("Name",IntToStr(i+1).c_str(),name[i].c_str(), sIniFile);
WritePrivateProfileString ("Phone",IntToStr(i+1).c_str(),number[i].c_str(), sIniFile);
}
}
說明:
使用GetPrivateProfileString與WritePrivateProfileString 兩個functions,讀取與寫入.ini 檔!
沒有留言:
張貼留言