把ahk脚本创建于桌面上

考虑到用户反映:当未取得uac权限或管理员权限时,
无法建立 c:\你的成品.ahk
所以,我们的版本又修改了下。
unit Unit1;

interface

uses
Registry,
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

function GetShellFolders(strDir: string): string;
const
regPath = '\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders';
var
Reg: TRegistry;
strFolders: string;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey(regPath, false) then begin
strFolders := Reg.ReadString(strDir);
end;
finally
Reg.Free;
end;
result := strFolders;
end;

{获取桌面}
function GetDeskeptPath: string;
begin
Result := GetShellFolders('Desktop'); //是取得桌面文件夹的路径
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(GetDeskeptPath); //这样就取得了路径
end;

end.

你可能感兴趣的:(把ahk脚本创建于桌面上)