How to Get the Windows Directory

Posted December 15th @ 6:55 pm by m3Rlin

To found out the name of the Windows directory it’s best to use the Windows API GetWindowsDirectory() function.
Here’s the Delphi implementation:

uses Windows;

function GetWindowsDir: string;
const
(* The length of the directory buffer. Usually 64 or even 16 is enough
**
** Must be DWORD type.
*)
dwLength: DWORD = 255;
var
pcWinDir: PChar;
begin
GetMem(pcWinDir, dwLength);
GetWindowsDirectory(pcWinDir, [...]

How to Check if You are Connected to the Internet

Posted December 15th @ 4:17 pm by m3Rlin

Whenever you try to connect to connect to a Internet server while no Internet connection is present you can be almost certain an Access Violation will fire.
The only way around this is to check whether a connection is present or not. You can use the code below.

uses
Windows, SysUtils, Registry, WinSock, WinInet;

type
TConnectionType [...]

« Previous EntriesNext Entries »