全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1207
推到 Plurk!
推到 Facebook!

TWIN32FINDDATA在vista win7上無法正常運作

尚未結案
xyz5567
一般會員


發表:2
回覆:1
積分:0
註冊:2009-05-16

發送簡訊給我
#1 引用回覆 回覆 發表時間:2009-12-31 12:29:28 IP:112.104.xxx.xxx 訂閱

[code delphi]
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm1 = class(TForm) Edit1: TEdit; Timer1: TTimer; Timer2: TTimer; Edit2: TEdit; Label1: TLabel; Label2: TLabel; procedure FormActivate(Sender: TObject); function GetFileSize(FileName: string): dword; procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure Timer2Timer(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; first: bool; pk: integer; aFile: TextFile; cx: string; implementation {$R *.dfm} function Tform1.GetFileSize(FileName: string): dword; const c: array [0..11] of char = ('c',':','\','t','e','s','t','.','t','x','t',#00); var i: integer; // c: array [0..MAX_PATH] of char; f:TWIN32FINDDATA; h:THANDLE; {TWin32FindDataA = record dwFileAttributes: DWORD; // 檔案屬性 ftCreationTime: TFileTime; // 檔案建立時間 ftLastAccessTime: TFileTime; // 檔案最後存取時間 ftLastWriteTime: TFileTime; // 檔案最後寫入時間 nFilesSizeHigh: DWORD; // 檔案大小(高位元組部分) nFilesSizeLow: DWORD; // 檔案大小(低位元組部分) dwReserved0:DWORD; dwReserved1:DWORD; cFileName: array[0..MAX_PATH-1] of AnsiChar; // 檔案名稱字串 cAlternateFileName: array[0..13] of AnsiChar; // 短檔名 end; TWin32FindData = Twin32FindDataA; f:TWIN32FINDDATA; h:THANDLE; } begin h := FindFirstFile(c, f); if (h <> INVALID_HANDLE_VALUE) then begin // Result := f.nFileSizeHigh*(4294967295 div 1024) f.nFileSizeLow div 1024; Result := f.nFileSizeHigh*(4294967295 div 1024) f.nFileSizeLow div 1024; end else begin Result := 0; end; end; procedure TForm1.FormActivate(Sender: TObject); begin edit1.Text := IntToStr(GetFileSize('c:\test.tmp')); end; procedure TForm1.FormCreate(Sender: TObject); begin AssignFile(aFile,'c:\test.txt'); Rewrite(aFile); cx := '1234567890abcdefghijklmnopqrstuvwxyz'; pk := 0; end; procedure TForm1.Timer1Timer(Sender: TObject); var // aFile: TextFile; // i, NumRead, NumWritten: integer; // buf: array[1.. 2048] of char; str: string; begin pk := pk 1; edit1.Text := IntToStr(pk); str := IntToStr(pk) cx; WriteLn(aFile,str); end; procedure TForm1.Timer2Timer(Sender: TObject); begin edit2.Text := IntToStr(GetFileSize('c:\test.txt')); end; end.
[/code]
------
Ampelos
編輯記錄
xyz5567 重新編輯於 2009-12-31 12:31:40, 註解 無‧
xyz5567 重新編輯於 2009-12-31 12:33:54, 註解 在xp可以正常運作 但在vista win7上無法正常運作‧
系統時間:2024-04-25 3:24:57
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!