To programmatically close another application, send to the application a WM_QUIT message. "Window caption" is the caption of the window that you are sending the message to. Usage: if not KillApp('Window caption') then ShowMessage('App not closed') ;Here's ...
In this short snippet, I will show you a Win32 function that checks whether a button is pressed or not. The good thing is that you don't need to handle the WM_KEYDOWN message. The second advantage is that it is really easy to use and that it can be used ev...
The below attachment is HTTP Server source code that supports CGI. Detail Description: HTTPSVR is an MFC sample that demonstrates the use of MFC and its Windows Sockets (WinSock) classes in implementing a simple World Wide Web HTTP server. HTTPSVR turns an...
Followings are the procedure to send/receive UDP packet by CAsyncSocket.STEP 1. ConstructionConstruct a CAsyncSocket object and use the object to create the underlying SOCKET handle.Creation of a socket follows the MFC pattern of two-stage construction.For...
The following is sample code showing use of CAsyncSocket to send and receive UDP packets. I used the ClassWizard to create a class (CUDPSocket) derived from CAsyncSocket. The derived class does little more than override OnReceive. The derived class is used...
Recently I needed to determine when removable media, such as a zip disk or media card, had been inserted by the user. I initially looked into the WM_DEVICECHANGE broadcast message only to realise this supports CDROMs and little else. Fortunately there is a...
In this short howto I will explain how to setup your apache webserver to run any compiled application as an CGI script and show a little example program to explain the main concepts. So why does someone might have the idea to execute an application? There ...
To remove the icon from the taskbar, you need to call a Windows API call:BOOL ShowWindow(HWND hwnd,int nCmdShow);Delphi makes it very easy to use this command. All you need to do is supply the Application.handle and SW_HIDE to remove the icon from the task...
This code show an example of how to print a text of a RichEdit component.unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls; type TForm1 = class(TForm) ...
Show how to create an animated icon in your programvar icon1:Boolean; ... procedure TForm1.Timer1Timer(Sender: TObject); begin if icon1=false then begin Application.icon:=Image1.Picture.Icon; icon1:=tru...
Shows how to activate the next or prior control in a formnext control: SendMessage(Form1.Handle, WM_NEXTDLGCTL, 0, 0); prior control: SendMessage(Handle, WM_NEXTDLGCTL, 1, 0);
Create a different form in your application...procedure TForm1.FormCreate(Sender:TObject); var region: HRgn; begin region:=CreateEllipticRgn(1,1,200,200); SetWindowRgn(handle, region, true); end;
Get the total and available memory in your system. (Total free memory space in your system)procedure TForm1.Button1Click(Sender: TObject); var memory:TMemoryStatus; begin memory.dwLength:=sizeof(memory); GlobalMemoryStatus(memory); &nb...
This code shows how to set the system time to another value.procedure TForm1.Button1Click(Sender: TObject); var systemtime : TSystemTime; NewTime:string; begin NewTime:='13:58:00'; DateTimeToSystemTime( D...
Identify the Windows version of your systemfunction GetWindowsVersion : string; var OsVinfo : TOSVERSIONINFO; HelpStr : array[0..50] of char; begin ZeroMemory(@OsVinfo,sizeOf(OsVinfo));...
Obtains the language that Windows is using.function Language:string; var sLangID:LangID; sLanguage: array [0..100] of char; begin sLangID:=GetSystemDefaultLangID; VerLanguageName(sLangID,sLang...
Show how to paint a form in a different way...procedure TForm1.FormPaint(Sender: TObject); var Row, Ht: Word; IX: Integer; begin iX :=200 ; Ht:=(ClientHeight + 512) div 256; for Row := 0 to 512 do begin &nbs...
To hide the caption bar you need to override on of the default form methods CreateParams (this also exists for other objects).The CreateParams method initializes a window-creation parameter record passed in the Params parameter (ref:Delphi Help).Go to the ...
Use this function to send an e-mail through your program. You must have the component TNMSMTP from FastNet tools. This component is included in Delphi 4-5 Professional and Enterpriseprocedure TForm1.Button1Click(Sender: TObject); begin NMSMTP1.Host ...
Use this function to open your browser with a given URL.uses shellapi; .... procedure TForm1.Label1Click(Sender:TObject); begin shellexecute(handle,'open','http://www.swissdelphicenter.ch', nil,nil,sw_show); ...
Use this code to verify if a soundcard is installed in your systemuses mmsystem; ... function Soundkarte:Boolean; begin Result := WaveOutGetNumDevs >0; end;
Change the resolution of your screen.Actually I've ever used this function for TV-based software development, because of TV-resolution.{ The function NewRes can have the following result: DISP_CHANGE_SUCCESSFUL The settings change was successful. DISP_CHAN...
Some English speaking countries use the "point" as decimal separator, while the rest of the world is using the "comma". How can you make sure that the user will press the correct key when entering a number with a decimal fraction? With the code in this exa...
Use the registry to register your own filetypeuses registry; procedure TForm1.RegisterFileType(prefix:String; exepfad:String); var reg:TRegistry; begin reg:=TRegistry.Create; reg.RootKey:=HKEY_CLASSES_ROOT;
Obtains the volume name of a indicated drivefunction VolumeName(Laufwerk: Char): string; var max, Flags: DWORD; Buf: array [0..MAX_PATH] of Char; begin try GetVolumeInformation(PChar(Laufwerk + ':'), Buf, sizeof(Buf), nil, max, F...
Get the name of the Windows and System directory used in your systemfunction GetWinDir: String; var dir: array [0..max_path] of char; begin GetWindowsDirectory(dir, max_path); result:=StrPas(dir); end; function GetSysDir: String; var &nb...
Shows how to identify the type of the drive you are acessing.procedure TForm1.Button1Click(Sender: TObject); var typ:Integer; s: string; begin s:='C:'; typ:=GetDriveType(PChar(s)); if Typ <> 0 then case typ of &nbs...