Search results for 'LoadLibrary'. 2 post(s) found.
- 2007/09/19 Disable Mouse and Keyboard from Delphi Code
- 2007/09/18 Are we connected to the Internet?
The BlockInput API function blocks keyboard and mouse input events from reaching applications.
Place a Button (name: "Button1") on a form (name: "Form1") and use this code for the button's OnClick event handler. Once you click the button your mouse and keyboard will be blocked for 5 seconds.
Note: BlockInput is available only on Windows 98 and newer,
this is why we have a "FuncAvaial" procedure - to test the existance of
a function inside a DLL.
procedure TForm1.Button1Click(Sender: TObject) ;
function FuncAvail(dllName, funcName: string; var p: pointer): boolean;
var
lib: THandle;
begin
result := false;
p := nil;
if LoadLibrary(PChar(dllName)) = 0 then exit;
lib := GetModuleHandle(PChar(dllName)) ;
if lib <> 0 then
begin
p := GetProcAddress(lib, PChar(funcName)) ;
if p <> nil then Result := true;
end;
end;
var
BlockInput : function(Block: BOOL): BOOL; stdcall;
begin
if FuncAvail('USER32.DLL', 'BlockInput', @BlockInput) then
begin
ShowMessage('Your Mouse and Keyboard will be blocked for 5 seconds!') ;
BlockInput(true) ;
Sleep(5000) ;
BlockInput(false) ;
end;
end;
end.
function FuncAvail(dllName, funcName: string; var p: pointer): boolean;
var
lib: THandle;
begin
result := false;
p := nil;
if LoadLibrary(PChar(dllName)) = 0 then exit;
lib := GetModuleHandle(PChar(dllName)) ;
if lib <> 0 then
begin
p := GetProcAddress(lib, PChar(funcName)) ;
if p <> nil then Result := true;
end;
end;
var
BlockInput : function(Block: BOOL): BOOL; stdcall;
begin
if FuncAvail('USER32.DLL', 'BlockInput', @BlockInput) then
begin
ShowMessage('Your Mouse and Keyboard will be blocked for 5 seconds!') ;
BlockInput(true) ;
Sleep(5000) ;
BlockInput(false) ;
end;
end;
end.
Another posts included in "Delphi"
| Display Standard Windows Properties dialog (0) | 2007/09/19 |
| Disable ALT+TAB, CTRL+ESC, CTRL+ALT+DEL (0) | 2007/09/19 |
| Get Windows Temp directory (0) | 2007/09/20 |
| Detecting Drive Types (0) | 2007/09/19 |
| Detecting and preventing Windows shut down (0) | 2007/09/19 |
| Create new program group in the Start menu (0) | 2007/09/19 |
| Copying Group of Files using Delphi with Standard Animation Dialog (SHF... (0) | 2007/09/19 |
| Controling sound volume from code (0) | 2007/09/19 |
Trackback : Cannot send a trackbact to this post.
-
Subject different money making ideas
2010/01/29 02:08
moneyideas
-
Subject different money making ideas
2010/01/29 10:30
moneyideas
-
Subject different money making ideas
2010/01/31 16:40
moneyideas
Here's how to check whether you are connected to the Internet
procedure TForm1.Button1Click(Sender: TObject) ;
function FuncAvail(_dllname, _funcname: string; var _p: pointer): boolean;
{return True if _funcname exists in _dllname}
var _lib: tHandle;
begin
Result := false;
if LoadLibrary(PChar(_dllname)) = 0 then exit;
_lib := GetModuleHandle(PChar(_dllname)) ;
if _lib <> 0 then begin
_p := GetProcAddress(_lib, PChar(_funcname)) ;
if _p <> NIL then Result := true;
end;
end;
{
Call SHELL32.DLL for Win < Win98
otherwise call URL.DLL
}
{button code:}
var
InetIsOffline : function(dwFlags: DWORD):
BOOL; stdcall;
begin
if FuncAvail('URL.DLL', 'InetIsOffline',
@InetIsOffline) then
if InetIsOffline(0) = true
then ShowMessage('Not connected')
else ShowMessage('Connected!') ;
end;
function FuncAvail(_dllname, _funcname: string; var _p: pointer): boolean;
{return True if _funcname exists in _dllname}
var _lib: tHandle;
begin
Result := false;
if LoadLibrary(PChar(_dllname)) = 0 then exit;
_lib := GetModuleHandle(PChar(_dllname)) ;
if _lib <> 0 then begin
_p := GetProcAddress(_lib, PChar(_funcname)) ;
if _p <> NIL then Result := true;
end;
end;
{
Call SHELL32.DLL for Win < Win98
otherwise call URL.DLL
}
{button code:}
var
InetIsOffline : function(dwFlags: DWORD):
BOOL; stdcall;
begin
if FuncAvail('URL.DLL', 'InetIsOffline',
@InetIsOffline) then
if InetIsOffline(0) = true
then ShowMessage('Not connected')
else ShowMessage('Connected!') ;
end;
Another posts included in "Delphi"
| Download a file from the Internet with progress indicator (0) | 2007/09/18 |
| Extracting the domain (host) name from an e-mail address (0) | 2007/09/18 |
| How to get get IE favorites (0) | 2007/09/18 |
| Rotate Bitmap (any angle, any center of rotation) (0) | 2007/09/11 |
| TImage.Bitmap fade out (0) | 2007/09/11 |
| TDesktopCanvas - draw on Windows Desktop (0) | 2007/09/11 |
| TColor to HTML color (0) | 2007/09/11 |
| Show *any* graphics as Glyph on a SpeedButton (0) | 2007/09/11 |
Trackback : Cannot send a trackbact to this post.
-
Subject different money making ideas
2010/01/29 02:08
moneyideas
-
Subject different money making ideas
2010/01/29 10:14
moneyideas
-
Subject different money making ideas
2010/01/31 16:40
moneyideas

Prev

Rss Feed