4-19
Saturday
标签
梦涛笔记

下面的例子演示怎样用Delphi得到BIOS数据

Delphi 发布时间:2025-03-13 14:16:29

下面的例子演示怎样用Delphi得到BIOS数据

procedure TForm1.BiosInfo;
const
Subkey: string = 'Hardwaredescriptionsystem';
var
hkSB: HKEY;
rType: LongInt;
ValueSize, OrigSize: Longint;
ValueBuf: array[0..1000] of char;
procedure ParseValueBuf(const VersionType: string);
var
I, Line: Cardinal;
S: string;
begin
i := 0;
Line := 0;
while ValueBuf[i] <> #0 do
begin
S := StrPas(@ValueBuf[i]); // move the Pchar into a string
Inc(Line);
Memo1.Lines.Append(Format('%s Line %d = %s',
[VersionType, Line, S])); // add it to a Memo
inc(i, Length(S) + 1);
// to point to next sz, or to #0 if at
end
end;
end;

begin
if RegOpenKeyEx(HKEY_LOCAL_MACHINE, PChar(Subkey), 0,
KEY_READ, hkSB) = ERROR_SUCCESS then
try
OrigSize := sizeof(ValueBuf);
ValueSize := OrigSize;
rType := REG_MULTI_SZ;
if RegQueryValueEx(hkSB, 'SystemBiosVersion', nil, @rType,
@ValueBuf, @ValueSize) = ERROR_SUCCESS then
ParseValueBuf('System BIOS Version');

ValueSize := OrigSize;
rType := REG_SZ;
if RegQueryValueEx(hkSB, 'SystemBIOSDate', nil, @rType,
@ValueBuf, @ValueSize) = ERROR_SUCCESS then
Memo1.Lines.Append('System BIOS Date ' + ValueBuf);

ValueSize := OrigSize;
rType := REG_MULTI_SZ;
if RegQueryValueEx(hkSB, 'VideoBiosVersion', nil, @rType,
@ValueBuf, @ValueSize) = ERROR_SUCCESS then
ParseValueBuf('Video BIOS Version');

ValueSize := OrigSize;
rType := REG_SZ;
if RegQueryValueEx(hkSB, 'VideoBIOSDate', nil, @rType,
@ValueBuf, @ValueSize) = ERROR_SUCCESS then
Memo1.Lines.Append('Video BIOS Date ' + ValueBuf);
finally
RegCloseKey(hkSB);
end;
end;


用Delphi 制作缩略图

Delphi 发布时间:2025-03-13 13:59:06
procedure SavePic(SourceFileName,DescFileName: String);
const
    MaxWidth = 80 ;
    MaxHigth = 80 ;
var
   jpg: TJPEGImage;
   bmp: TBitmap;
   SourceJpg: TJPEGImage;
   Width, Height,tmpInt: Integer;
begin
   try
     bmp := TBitmap.Create;
     SourceJpg := TJPEGImage.Create;
     Jpg:= TJPEGImage.Create;
     //读取源文件
     SourceJpg.LoadFromFile(SourceFileName);
     //计算缩小比例
     if SourceJpg.Width >= SourceJpg.Height then
        tmpInt := Round(SourceJpg.Width div MaxWidth)
     else
        tmpInt := Round(SourceJpg.Height div MaxHigth) ;
     Width  := SourceJpg.Width  div tmpInt ;
     Height := SourceJpg.Height div tmpInt ;
     //缩小
     bmp.Width := Width;
     bmp.Height := Height;
     bmp.PixelFormat := pf24bit;
     bmp.Canvas.StretchDraw(Rect(0,0,Width,Height), SourceJpg);
     //保存
     jpg.Assign(bmp);
     jpg.SaveToFile(DescFileName);
   finally
     bmp.Free;
     jpg.Free;
     SourceJpg.Free;
   end;
end;