萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> 編程語言綜合 >> delphi編程控制INI文件

delphi編程控制INI文件

  從.INI文件中獲取字符串

  var

  strResult:pchar;

  begin

  GetPrivateProfileString(

  'windows', // []中標題的名字

  'NullPort', // =號前的名字

  'NIL', // 如果沒有找到字符串時,返回的默認值

  strResult, //存放取得字符

  100, //取得字符的允許最大長度

  'c:forwin95win.ini' // 調用的文件名

  );

  edit1.text:=strResult; //顯示取得字符串

  從.INI文件中獲取整數

  edit1.text:=inttostr(GetPrivateProfileInt(

  'intl', // []中標題的名字

  'iCountry', // =號前的名字

  0,// 如果沒有找到整數時,返回的默認值

  'c:forwin95win.ini' // 調用的文件名

  ));

  向.INI文件寫入字符串

  WritePrivateProfileString(

  'windows', // []中標題的名字

  'load', // 要寫入“=”號前的字符串

  'accca', //要寫入的數據

  'c:forwin95win.ini' // 調用的文件名

  );

  向.INI文件寫入整數

  WritePrivateProfileSection(

  'windows', // []中標題的名字

  'read=100', // 要寫入的數據

  'c:forwin95win.ini' // 調用的文件名

  );

copyright © 萬盛學電腦網 all rights reserved