Archiv für Delphi
Checking available disk space on large drives
Samstag, 12. Mai 20072GB, CheckDiskSpace, Large Disk
Question and Answer Database
FAQ2552D.txt Checking available disk space on large drives.
Category :Windows API
Platform :All
Product :All 32 bit
Question:
How do I check for available diskspace on a drive larger than 2
gigabytes?
Answer:
You will need to call the Windows API function GetDiskFreeSpaceEx()
and convert the returned integers to doubles, since integers greater
than 2 gigabytes are not supported in Delphi.
Example:
weiterlesen »
creating a Shortcut to a file
Samstag, 12. Mai 2007Icon Shortcut Verknüpfung anlegen
You can try the code below – maybe you needed CoInitialize?
The code works fine for me on NT and 98, using Delphi4.
weiterlesen »
Get an EXEs Version-Information
Samstag, 12. Mai 2007Q: How to get an EXEs Version-Information:
A: (found on a Newsgroup from Glenn Hancock)
Yes it is and here is a function that we use. Try it out and it should
provide you the information your looking for. This function only gives you
the version which is what we are most concerned with…
Good luck,
weiterlesen »
Get CPU speed
Samstag, 12. Mai 2007I’m not all that good at ASM so what all this does
I can’t explain in much detail.
var
t: DWORD;
mhi, mlo, nhi, nlo: DWORD;
t0, t1, chi, clo, shr32: Comp;
begin
shr32 := 65536;
shr32 := shr32 * 65536;
t := GetTickCount;
while t = GetTickCount do begin end;
asm
DB 0FH
DB 031H
mov mhi,edx
mov mlo,eax
end;
while GetTickCount < (t + 1000) do begin end;
asm
DB 0FH
DB 031H
mov nhi,edx
mov nlo,eax
end;
chi := mhi; if mhi < 0 then chi := chi + shr32;
clo := mlo; if mlo < 0 then clo := clo + shr32;
t0 := chi * shr32 + clo;
chi := nhi; if nhi < 0 then chi := chi + shr32;
clo := nlo; if nlo < 0 then clo := clo + shr32;
t1 := chi * shr32 + clo;
Result := (t1 - t0) / 1E6;
end;
//and example call
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.Caption := FloatToStr(GetCpuSpeed) + ‘mhz’;
end;
[tags]Delphi, System[/tags]
Get the OS-Version
Samstag, 12. Mai 2007How to get the OS-Version?
Solution by GRS:
// —— Code starts ——
weiterlesen »
GetDiskFreeSpace
Samstag, 12. Mai 2007Var
RootPath : String;
Sec_Cluster, Bytes_Sec, Free_Clusters, Total_Clusters : DWord;
begin
// Set the Drive to check
RootPath := ‘C:\’;
GetDiskFreeSpace(PChar(RootPath), Sec_Cluster, Bytes_Sec, Free_Clusters, Total_Clusters);
// Lets put information into a ListBox
ListBox1.Items.Add(‘RootPath : ‘ + RootPath);
ListBox1.Items.Add(‘Sectors Per Cluster : ‘ + IntToStr(Sec_Cluster));
ListBox1.Items.Add(‘Bytes Per Sector : ‘ + IntToStr(Bytes_Sec));
ListBox1.Items.Add(‘Free Clusters : ‘ + IntToStr(Free_Clusters));
ListBox1.Items.Add(‘Total Clusters : ‘ + IntToStr(Total_Clusters));
ListBox1.Items.Add(‘Free Bytes : ‘ + IntToStr(Bytes_Sec * Sec_Cluster * Free_Clusters));
ListBox1.Items.Add(‘Total Bytes : ‘ + IntToStr(Bytes_Sec * Sec_Cluster * Total_Clusters));
end;
[tags]Delphi, System[/tags]
GetFileDate
Samstag, 12. Mai 2007Var
S1 : String;
F1 : File;
FStruct : TOFSTRUCT;
TheDate : TDateTime;
Han1 : Integer;
I : Integer;
begin
S1 := FileListBox1.Filename;
Han1 := OpenFile(PChar(S1), FStruct, OF_SHARE_DENY_NONE);
I := FileGetDate(Han1);
TheDate := FileDateToDateTime(I);
Label4.Caption := DateTimeToStr(TheDate);
_lclose(Han1);
end;
[tags]Delphi, System, Files[/tags]
Key Codes
Samstag, 12. Mai 2007{ Virtual Keys, Standard Set }
VK_LBUTTON = 1;
VK_RBUTTON = 2;
VK_CANCEL = 3;
VK_MBUTTON = 4; { NOT contiguous with L & RBUTTON }
VK_BACK = 8;
VK_TAB = 9;
VK_CLEAR = 12;
VK_RETURN = 13;
VK_SHIFT = $10;
VK_CONTROL = 17;
VK_MENU = 18;
weiterlesen »
Keys Status
Samstag, 12. Mai 2007const
CapPanel = 1;
NumPanel = 2;
ScrlPanel = 3;
DatePanel = 4;
begin
with StatusBar1 do
begin
if GetKeyState(VK_CAPITAL) <> 0 then
StatusBar1.Panels[CapPanel].Text := ‘ CAP’
else
StatusBar1.Panels[CapPanel].Text := ”;
if GetKeyState(VK_NUMLOCK) <> 0 then
StatusBar1.Panels[NumPanel].Text := ‘ NUM’
else
StatusBar1.Panels[NumPanel].Text := ”;
if GetKeyState(VK_SCROLL) <> 0 then
StatusBar1.Panels[ScrlPanel].Text := ‘ SCRL’
else
StatusBar1.Panels[ScrlPanel].Text := ”;
StatusBar1.Panels[DatePanel].Text := FormatDateTime(‘ mmmm D, YYYYY’, now);
end;
End;
[tags]Delphi, System, Keyboard[/tags]
SetFileDate
Samstag, 12. Mai 2007Var
S1 : String;
FHan : Integer;
I2 : Integer;
S2 : String;
S3 : String;
FStruct : TOFSTRUCT;
FStruct2 : TOFSTRUCT;
TheDate : TDateTime;
TheDate2 : TDateTime;
FHan2 : Integer;
I3 : Integer;
begin
S3 := Directory95ListBox1.Directory;
If S3[Length(S3)] <> ‘\’ Then S3 := S3 + ‘\’;
S1 := FileListBox1.Filename;
// Here is another file to get the date from
S2 := S3 + FileListBox1.Items.Strings[5];
FHan2 := OpenFile(PChar(S2), FStruct2, OF_READWRITE);
I2 := FileGetDate(FHan2);
// ^^^^^^
FHan := OpenFile(PChar(S1), FStruct, OF_READWRITE);
I3 := FileSetDate(FHan, I2);
TheDate := FileDateToDateTime(I2);
TheDate2 := FileDateToDateTime(I2);
_lclose(FHan);
_lclose(FHan2);
Label1.Caption := DateTimeToStr(TheDate);
Label2.Caption := IntToStr(I3);
end;
[tags]Delphi, System, Files[/tags]