請問GetCurrentDirectory如何使用 |
答題得分者是:Stallion
|
pceyes
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
win32.hlp 內說明如下:
DWORD GetCurrentDirectory( DWORD nBufferLength, // size, in characters, of directory buffer LPTSTR lpBuffer // address of buffer for current directory ); Parameters nBufferLength Specifies the length, in characters, of the buffer for the current directory string. The buffer length must include room for a terminating null character. lpBuffer Points to the buffer for the current directory string. This null-terminated string specifies the absolute path to the current directory. 我改的程式卻不work, 請協助修正, 謝謝! <textarea cols="60" rows="10" class="delphi" name="code">Program Test; function GetCurrentDirectory(C1: string;C2:PCHAR):string;external 'GetCurrentDirectoryA@KERNEL32.dll stdcall'; var CurrDir: array[0..99] of char; begin GetCurrentDirectory(SizeOf(CurrDir),CurrDir); WriteLn(CurDir); end; End. </textarea>
------
努力會更接近成功 編輯記錄
pceyes 重新編輯於 2007-08-16 22:29:38, 註解 程式碼排版‧
|
Stallion
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:52 回覆:1600 積分:1995 註冊:2004-09-15 發送簡訊給我 |
|
pceyes
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
謝謝指導,
錯誤訊息如下: [Error] C:\Program Files\RemObjects Software\Pascal Script for Delphi\Samples\Import\GETDIR.rops(11:19): Unknown identifier 'MAX_PATH' ===================引 用 Stallion 文 章=================== 看不出來你要作啥?!這個API要這樣用。 var aPath:String; SetLength(aPath,MAX_PATH); Len := Windows.GetCurrentDirectory(MAX_PATH,PChar(aPath)); SetLength(aPath,Len); ShowMessage(aPath);
------
努力會更接近成功 |
Stallion
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:52 回覆:1600 積分:1995 註冊:2004-09-15 發送簡訊給我 |
Uses
Windows; ===================引 用 pceyes 文 章=================== 謝謝指導, 錯誤訊息如下: [Error] C:\Program Files\RemObjects Software\Pascal Script for Delphi\Samples\Import\GETDIR.rops(11:19): Unknown identifier 'MAX_PATH' ===================引 用 Stallion 文 章=================== 看不出來你要作啥?!這個API要這樣用。 var aPath:String; SetLength(aPath,MAX_PATH); Len := Windows.GetCurrentDirectory(MAX_PATH,PChar(aPath)); SetLength(aPath,Len); ShowMessage(aPath); |
pceyes
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
改成這樣就可以了, 謝謝您的指教! <textarea name="code" class="delphi" rows="600" cols="800">
Program Test; function GetCurrentDirectory(C1: longint;C2:PCHAR):longint;external 'GetCurrentDirectoryA@KERNEL32.dll stdcall'; var
aPath:String;
len : longint;
begin
SetLength(aPath,256);
Len := GetCurrentDirectory(256,PChar(aPath));
SetLength(aPath,Len);
writeln(apath); End.
</textarea>
------
努力會更接近成功 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |