Convert Enum to String using Delphi

uses
TypInfo;

type
Language = (Delphi,Delphi_Prism,CBuilder);

var
StrLanguage : String;
begin
StrLanguage := GetEnumName(TypeInfo(Language),integer(Delphi)) ;
end;

uses
TypInfo;

type
Language = (Delphi,Delphi_Prism,CBuilder);

var
aLanguage : Language;
begin
aLanguage := Language(GetEnumValue(TypeInfo(Language),'CBuilder')) ;
end;

检查Delphi程序是否在64位系统中运行

uses Windows;

type
WinIsWow64 = function( Handle: THandle; var Iret: BOOL ): Windows.BOOL; stdcall;

function IAmIn64Bits: Boolean;
var
HandleTo64BitsProcess: WinIsWow64;
Iret : Windows.BOOL;
begin
Result := False;
HandleTo64BitsProcess := GetProcAddress(GetModuleHandle('kernel32.dll'), 'IsWow64Process');
if Assigned(HandleTo64BitsProcess) then
begin
if not HandleTo64BitsProcess(GetCurrentProcess, Iret) then
Raise Exception.Create('Invalid handle');
Result := Iret;
end;
end;

...get the pathes of the windows special folders?

uses
ActiveX, ShlObj;

procedure TForm1.Button1Click(Sender: TObject);
// Replace CSIDL_HISTORY with the constants below
var
Allocator: IMalloc;
SpecialDir: PItemIdList;
FBuf: array[0..MAX_PATH] of Char;
PerDir: string;
begin
if SHGetMalloc(Allocator) = NOERROR then
begin
SHGetSpecialFolderLocation(Form1.Handle, CSIDL_HISTORY, SpecialDir);
SHGetPathFromIDList(SpecialDir, @FBuf[0]);
Allocator.Free(SpecialDir);
ShowMessage(string(FBuf));
end;
end;

// With Windows Me/2000, the SHGetSpecialFolderLocation function

Lazarus webbrowser

QT Webkit

When using the Qt WidgetSet, you can use the Qt WebKit to embed a browser into a LCL form.

Lazarus LCL/Qt WebKit Demo available on FPC Qt4 Binding Web Page

 

Finding the default webbrowser

Every platform has a mechanism for its default platform. The LCL unit lazhelphtml contains a class THTMLBrowserHelpViewer to start a web browser for the LCL help system. You can use its method FindDefaultBrowser to find the default browser and the parameter to start. For example:

 

Vista Compatible Open/Save Dialogs in Lazarus

{
  VistaOpenSaveDialog:
  A new Open/Save dialog that uses Windows API to display Vista
  compatiable Open or Save Dialog.
 
  Tested in Windows 2000/XP/Vista/Vista x64.
  Compiled with Lazarus 0.9.29 beta (21448) / FreePascal 2.2.4
  It should compile successfully with all newer and maybe some the versions.
 
  Created by Iskren Slavov (http://www.dotfusion.net/).
  No right reserved. Feel free to use for any of your applications
  regardless of the license.
 
  ##########################################
 
  Example usage:

Changing the screen resolution programmatically

SetScreenResolution
To change the screen resolution you can use the following function which is a wrapper for the Windows API ChangeDisplaySettings. Below is the source code of a function that takes the desired width and height as parameters and returns the return value of ChangeDisplaySettings (see the documentation for more details).
 

How to open a web site with the default web browser in a NEW window

uses
   Registry, ShellAPI;
 
function BrowseURL(const URL: string) : boolean;
var
   Browser: string;
begin
   Result := True;
   Browser := '';
   with TRegistry.Create do
   try
     RootKey := HKEY_CLASSES_ROOT;
Access := KEY_QUERY_VALUE;
     if OpenKey('\htmlfile\shell\open\command', False) then
       Browser := ReadString('') ;
     CloseKey;
   finally
     Free;
   end;
   if Browser = '' then
   begin
     Result := False;
     Exit;
   end;
   Browser := Copy(Browser, Pos('"', Browser) + 1, Length(Browser)) ;
   Browser := Copy(Browser, 1, Pos('"', Browser) 

Extract Links From an HTML Page Using Delphi

In most situations you use the TWebBrowser to display HTML documents to the user - thus creating your own version of the (Internet Explorer) Web browser.

Syndicate content Syndicate content