⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 my_api_for_systemini.pas

📁 是和Delphi 编程精选集锦书本配套的源码
💻 PAS
字号:
// Author:Youzhen
// Date: 2000/08/09
// Version: 1.0
//
// This Is A Dll File For Config ScreenSave
//
// Don't Use TString In Dll File !
// Use shortstring Instead of TString !
//
// Topic Function:
//         GetProvideProfileString
//         WriteProvideProfileString
//         GetMem
//         StrPCopy
//         FreeMem
//
//************************************************//

unit My_API_for_Systemini;

interface

uses
  Windows, SysUtils;

procedure My_GetPrivateProfileString(
            My_lpAppName,
            My_lpKeyName,
            My_lpDefault:shortstring;
            var My_lpReturnedString:shortstring;
            My_nSize:dword;
            My_lpFileName:shortstring);

procedure My_WritePrivateProfileString(
            My_lpAppName,
            My_lpKeyName,
            My_String,
            My_lpFileName:shortstring);

implementation

                                                procedure My_GetPrivateProfileString(
            My_lpAppName,
            My_lpKeyName,
            My_lpDefault:shortstring;
            var My_lpReturnedString:shortstring;
            My_nSize:dword;
            My_lpFileName:shortstring);

var lpAppName,  // points to section name
    lpKeyName,	// points to key name
    lpDefault,  // points to default string
    lpReturnedString:pchar;  // points to destination buffer
    nSize:dword;	// size of destination buffer
    lpFileName:pchar;

  begin
    GetMem(lpAppName,100);
    GetMem(lpKeyName,100);
    GetMem(lpDefault,100);
    GetMem(lpReturnedString,100);
    GetMem(lpFileName,100);

    StrPCopy(lpAppName,My_lpAppName);
    StrPCopy(lpKeyName,My_lpKeyName);
    StrPCopy(lpDefault,My_lpDefault);
    StrPCopy(lpFileName,My_lpFileName);
    
    nSize:=My_nSize;
    //%%%即先为返回字符串指定足够的空间%%%

    GetPrivateProfileString(
        lpAppName,lpKeyName,lpDefault,lpReturnedString,
        nSize,lpFileName);

    My_lpReturnedString:=StrPas(lpReturnedString);

    FreeMem(lpAppName,100);
    FreeMem(lpKeyName,100);
    FreeMem(lpDefault,100);
    FreeMem(lpReturnedString,100);
    FreeMem(lpFileName,100);
  end;


procedure My_WritePrivateProfileString(
            My_lpAppName,
            My_lpKeyName,
            My_String,
            My_lpFileName:shortstring);

var lpAppName,	// pointer to section name
    lpKeyName,	// pointer to key name
    lpString,	// pointer to string to add
    lpFileName:PChar; 	// pointer to initialization filename

  begin
    GetMem(lpAppName,100);
    GetMem(lpKeyName,100);
    GetMem(lpString,100);
    GetMem(lpFileName,100);

    StrPCopy(lpAppName,My_lpAppName);
    StrPCopy(lpKeyName,My_lpKeyName);
    StrPCopy(lpString,My_String);
    StrPCopy(lpFileName,My_lpFileName);

    WritePrivateProfileString(
      lpAppName,lpKeyName,lpString,lpFileName);

    FreeMem(lpAppName,100);
    FreeMem(lpKeyName,100);
    FreeMem(lpString,100);
    FreeMem(lpFileName,100);
  end;
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -