Buenas maestros, por favor, como hago esto usando FIVEWIN y XHARBOUR?
http://www.codeproject.com/KB/winsdk/An ... nLock.aspx
Gracias,
Saludos.
Buenas maestros, por favor, como hago esto usando FIVEWIN y XHARBOUR?
http://www.codeproject.com/KB/winsdk/An ... nLock.aspx
Gracias,
Saludos.
Rossine wrote:Olá João,
Mira aqui: http://www.fivewin.com.br/exibedicas.asp?id=795
Abraços,
Rossine.
karinha wrote:Mas no me gusta usar DLL de terceros.Hola João
#include "fivewin.ch"
Function Main()
msgstop( StartButton( .F. ), "Desabilitando o botão Start - Win 9x, NT, 2K, XP" )
msgstop( StartButton( .T. ), "Habilitando o botão Start - Win 9x, NT, 2K, XP" )
msgstop( ShowDesktop( .F. ), "Desabilitando o Desktop - Win 9x, NT, 2K, XP" )
msgstop( DesktopProc( "MyDesktop2", "Calc.exe" ), "Executando uma tarefa em outro desktop - Win NT, 2K, XP" )
msgstop( ShowDesktop( .T. ), "Habilitando o Desktop - Win 9x, NT, 2K, XP" )
msgstop( ShowTaskbar( .F. ), "Desabilitando o Taskbar - Win 9x, NT, 2K, XP" )
msgstop( ShowTaskbar( .T. ), "Habilitando o Taskbar - Win 9x, NT, 2K, XP" )
msgstop( ShowClock( .F. ), "Desabilitando o Clock - Win 9x, NT, 2K, XP" )
msgstop( ShowClock( .T. ), "Habilitando o Clock - Win 9x, NT, 2K, XP" )
msgstop( AltTabEnable( 0, .F. ), "Desabilitando ALT+TAB e ALT+ESC - Windows NT, 2k" )
msgstop( AltTabEnable( 0, .T. ), "Habilitando ALT+TAB e ALT+ESC - Windows NT, 2k" )
msgstop( CtrlAltDel( .F. ), "Desabilitando o CtrlAltDel - Windows NT, 2k" )
msgstop( CtrlAltDel( .T. ), "Habilitando o CtrlAltDel - Windows NT, 2k" )
Return Nil
#pragma BEGINDUMP
#include <windows.h>
#include <stdlib.h>
#include <hbapi.h>
#define ID_STARTBUTTON 0x130 // Start button ID
#define ID_TRAY 0x12F // System tray ID
#define ID_CLOCK 0x12F // System clock ID
#define PROGRAM_MANAGER "Program Manager" // Program manager window name
#define TASKBAR "Shell_TrayWnd" // Taskbar class name
int WINAPI TaskManager_Enable_Disable( BOOL ) ;
int WINAPI StartButton_Show_Hide( BOOL ) ;
int WINAPI Desktop_Show_Hide( BOOL ) ;
int WINAPI Process_Desktop(char *, char * ) ;
int WINAPI Taskbar_Show_Hide( BOOL ) ;
int WINAPI Clock_Show_Hide( BOOL ) ;
int WINAPI AltTab_Enable_Disable( HWND, BOOL ) ;
BOOL StartProcess( char *, char * ) ;
LRESULT CALLBACK LowLevelMouseHookProc( int nCode, WORD wParam, DWORD lParam ) ;
LRESULT CALLBACK MouseHookProc( int nCode, WORD wParam, DWORD lParam ) ;
HHOOK hHook ; // Mouse hook
HINSTANCE hInst ; // Instance handle
HB_FUNC( ALTTABENABLE )
{
HWND hWnd = (HWND ) hb_parnl( 1 ) ;
BOOL bEnable = hb_parl( 2 ) ;
int iRet ;
iRet = AltTab_Enable_Disable( hWnd, bEnable ) ;
hb_retni( iRet ) ;
}
HB_FUNC( SHOWCLOCK )
{
BOOL bShow = hb_parl( 1 ) ;
int iRet ;
iRet = Clock_Show_Hide( bShow ) ;
hb_retni( iRet ) ;
}
HB_FUNC( SHOWTASKBAR )
{
BOOL bShow = hb_parl( 1 ) ;
int iRet ;
iRet = Taskbar_Show_Hide( bShow ) ;
hb_retni( iRet ) ;
}
HB_FUNC( DESKTOPPROC )
{
char* c1 = hb_parc( 1 ) ;
char* c2 = hb_parc( 2 ) ;
int iRet ;
iRet = Process_Desktop( c1, c2 ) ;
hb_retni( iRet ) ;
}
HB_FUNC( SHOWDESKTOP )
{
BOOL bShow = hb_parl( 1 ) ;
int iRet ;
iRet = Desktop_Show_Hide( bShow ) ;
hb_retni( iRet ) ;
}
HB_FUNC( STARTBUTTON )
{
BOOL bShow = hb_parl( 1 ) ;
int iRet ;
iRet = StartButton_Show_Hide( bShow ) ;
hb_retni( iRet ) ;
}
HB_FUNC( CTRLALTDEL )
{
BOOL bEnable = hb_parl( 1 ) ;
int iRet ;
iRet = TaskManager_Enable_Disable( bEnable ) ;
hb_retni( iRet ) ;
}
int WINAPI TaskManager_Enable_Disable(BOOL bEnableDisable)
{
#define KEY_DISABLETASKMGR "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"
#define VAL_DISABLETASKMGR "DisableTaskMgr"
HKEY hKey;
DWORD val;
LONG r;
if (RegOpenKey(HKEY_CURRENT_USER, KEY_DISABLETASKMGR, &hKey) != ERROR_SUCCESS)
if (RegCreateKey(HKEY_CURRENT_USER, KEY_DISABLETASKMGR, &hKey) != ERROR_SUCCESS)
return 0;
if (bEnableDisable) // Enable
{
r = RegDeleteValue(hKey, VAL_DISABLETASKMGR);
}
else // Disable
{
val = 1;
r = RegSetValueEx(hKey, VAL_DISABLETASKMGR, 0, REG_DWORD, (BYTE *)&val, sizeof(val));
}
RegCloseKey(hKey);
return (r == ERROR_SUCCESS ? 1 : 0) ;
}
int WINAPI StartButton_Show_Hide( BOOL bShowHide )
{
HWND hWnd;
hWnd = GetDlgItem( FindWindow( TASKBAR, NULL ), ID_STARTBUTTON ) ;
if ( hWnd == NULL )
return 0 ;
ShowWindow( hWnd, bShowHide ? SW_SHOW : SW_HIDE) ;
UpdateWindow( hWnd );
return 1 ;
}
int WINAPI Taskbar_Show_Hide( BOOL bShowHide )
{
HWND hWnd;
hWnd = FindWindow( TASKBAR, NULL ) ;
if ( hWnd == NULL )
return 0 ;
ShowWindow( hWnd, bShowHide ? SW_SHOW : SW_HIDE ) ;
UpdateWindow(hWnd) ;
return 1 ;
}
int WINAPI Desktop_Show_Hide( BOOL bShowHide )
{
OSVERSIONINFO osvi ;
BOOL bIsWindowsNT4SP3orLater ;
int iServicePack ;
char *p ;
// Determine the current windows version
osvi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ) ;
GetVersionEx( &osvi );
for (p = osvi.szCSDVersion; *p && ! isdigit( *p ) ; *p++ ) ;
iServicePack = atoi( p ) ;
bIsWindowsNT4SP3orLater = ( osvi.dwPlatformId == VER_PLATFORM_WIN32_NT ) &&
( ( ( osvi.dwMajorVersion == 4 ) && ( iServicePack >= 3 ) ) ||
( osvi.dwMajorVersion > 4 ) ) ;
if ( ! bShowHide )
{
if ( ! hHook )
{
hHook = SetWindowsHookEx( bIsWindowsNT4SP3orLater ? WH_MOUSE_LL : WH_MOUSE,
bIsWindowsNT4SP3orLater ? ( HOOKPROC )LowLevelMouseHookProc : ( HOOKPROC )MouseHookProc,
hInst, 0 ) ;
if ( ! hHook )
return 0 ;
}
}
else
{
UnhookWindowsHookEx(hHook);
hHook = NULL;
}
return SetWindowPos( FindWindow( NULL, PROGRAM_MANAGER ), NULL, 0, 0, 0, 0,
bShowHide ? SWP_SHOWWINDOW : SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
}
LRESULT CALLBACK LowLevelMouseHookProc( int nCode, WORD wParam, DWORD lParam )
{
PMSLLHOOKSTRUCT p = (PMSLLHOOKSTRUCT)lParam ;
HWND hWnd = WindowFromPoint( p->pt ) ;
if( nCode >= 0 )
{
if ( ( wParam == WM_LBUTTONDOWN || wParam == WM_RBUTTONDOWN ) && hWnd == GetDesktopWindow() )
{
return 1 ;
}
}
return CallNextHookEx( hHook, nCode, wParam, lParam ) ;
}
LRESULT CALLBACK MouseHookProc( int nCode, WORD wParam, DWORD lParam )
{
if( nCode >= 0 )
{
if ( wParam == WM_LBUTTONDBLCLK )
{
if ( ( ( MOUSEHOOKSTRUCT * )lParam )->hwnd == GetDesktopWindow() )
{
return 1 ;
}
}
}
return CallNextHookEx( hHook, nCode, wParam, lParam ) ;
}
int WINAPI Process_Desktop(char *szDesktopName, char *szPath )
{
HDESK hOriginalThread ;
HDESK hOriginalInput ;
HDESK hNewDesktop ;
// Save original ...
hOriginalThread = GetThreadDesktop( GetCurrentThreadId() ) ;
hOriginalInput = OpenInputDesktop( 0, FALSE, DESKTOP_SWITCHDESKTOP ) ;
// Create a new Desktop and switch to it
hNewDesktop = CreateDesktop( szDesktopName, NULL, NULL, 0, GENERIC_ALL, NULL ) ;
SetThreadDesktop( hNewDesktop ) ;
SwitchDesktop( hNewDesktop ) ;
// Execute process in new desktop
StartProcess( szDesktopName, szPath ) ;
// Restore original ...
SwitchDesktop( hOriginalInput ) ;
SetThreadDesktop( hOriginalThread ) ;
// Close the Desktop
CloseDesktop( hNewDesktop ) ;
return 0 ;
}
BOOL StartProcess( char *szDesktopName, char *szPath )
{
STARTUPINFO si ;
PROCESS_INFORMATION pi ;
// Zero these structs
ZeroMemory( &si, sizeof( si ) ) ;
si.cb = sizeof( si ) ;
si.lpTitle = szDesktopName ;
si.lpDesktop = szDesktopName ;
ZeroMemory( &pi, sizeof( pi ) ) ;
// Start the child process
if (!CreateProcess( NULL, // No module name (use command line).
szPath, // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) ) // Pointer to PROCESS_INFORMATION structure.
{
return FALSE ;
}
// Wait until process exits
WaitForSingleObject( pi.hProcess, INFINITE ) ;
// Close process and thread handles
CloseHandle( pi.hProcess ) ;
CloseHandle( pi.hThread ) ;
return TRUE ;
}
int WINAPI Clock_Show_Hide( BOOL bShowHide )
{
HWND hWnd ;
hWnd = GetDlgItem( FindWindow( TASKBAR, NULL ), ID_TRAY ) ;
hWnd = GetDlgItem( hWnd, ID_CLOCK ) ;
if ( hWnd == NULL )
return 0 ;
ShowWindow( hWnd, bShowHide ? SW_SHOW : SW_HIDE ) ;
UpdateWindow( hWnd ) ;
return 1 ;
}
int WINAPI AltTab_Enable_Disable( HWND hWnd, BOOL bEnableDisable )
{
#define m_nHotKeyID 100
if ( ! bEnableDisable )
{
if ( ! RegisterHotKey( hWnd, m_nHotKeyID+0, MOD_ALT, VK_TAB ) ) // Alt+Tab
return 0 ;
if ( ! RegisterHotKey( hWnd, m_nHotKeyID+1, MOD_ALT, VK_ESCAPE ) ) // Alt+Esc
return 0 ;
}
else
{
if ( ! UnregisterHotKey( hWnd, m_nHotKeyID + 0 ) )
return 0 ;
if ( ! UnregisterHotKey( hWnd, m_nHotKeyID + 1 ) )
return 0 ;
}
return 1 ;
}
#pragma ENDDUMPGracias amado Maestro, voy probar.
Tengo que decir, que és una persona marabillosa!!
Muchas gracias.
Regards, saludos.
Maestro Manuel... Sin palablas, SIMPLESMENTE, FANTASTICO!!
PERFECTO, MUI BUENO!! UN SUEÑO.
MIL GRACIAS.
Regards, saludos.
/*
06/07/07 - Desativar teclas especiais
Olá,
Neste exemplo que fiz associado a dll que é encontrada no endereço:
http://www.codeproject.com/win32/AntonioWinLock.asp
...é possÃvel fazer o seguinte em FWH:
- Ativa/Desativar alt+tab
- Ativa/Desativar alt+esc
- Ativa/Desativar ctrl+alt+del
- Mostrar/Esconder a barra de tarefas
- Mostrar/Esconder o desktop
- Mostrar/Esconder o Start Button
- Mostrar/Esconder o System Clock
- Rodar um processo em outro desktop
Espero que gostem :-)
Abraços,
Rossine.
esta em ALTTAB.ZIP em dicas mais dicas
==============================================================================
En: 21/08/2008 - Manuel Mercado Gentilmente Converteu Para FIVEWIN FOR XHARBOUR
Hola João
Una conversión rápida del ejemplo de Rossine a su versión en C directamente
con FWH sin Dll's
Manuel Mercado
*/
#Include "FiveWin.Ch"
#Include "Dll.Ch"
Function Main()
MsgStop( StartButton( .F. ), "Desabilitando o botão Start(Iniciar) - Win 9x, NT, 2K, XP" )
MsgStop( StartButton( .T. ), "Habilitando o botão Start(Iniciar) - Win 9x, NT, 2K, XP" )
MsgStop( ShowDesktop( .F. ), "Desabilitando o Desktop - Win 9x, NT, 2K, XP" )
MsgStop( DesktopProc( "MyDesktop2", "Calc.exe" ), "Executando uma tarefa em outro desktop - Win NT, 2K, XP" )
MsgStop( ShowDesktop( .T. ), "Habilitando o Desktop - Win 9x, NT, 2K, XP" )
MsgStop( ShowTaskbar( .F. ), "Desabilitando o Taskbar(Barra de Tarefas) - Win 9x, NT, 2K, XP" )
MsgStop( ShowTaskbar( .T. ), "Habilitando o Taskbar(Barra de Tarefas) - Win 9x, NT, 2K, XP" )
MsgStop( ShowClock( .F. ), "Desabilitando o Clock(Relogio) - Win 9x, NT, 2K, XP" )
MsgStop( ShowClock( .T. ), "Habilitando o Clock(Relogio) - Win 9x, NT, 2K, XP" )
MsgStop( AltTabEnable( 0, .F. ), "Desabilitando ALT+TAB e ALT+ESC - Windows NT, 2k" )
MsgStop( AltTabEnable( 0, .T. ), "Habilitando ALT+TAB e ALT+ESC - Windows NT, 2k" )
// Para Windows XP/NT e 2000 / 2003
IF IsWinNT() .OR. IsWin2000() //??? Nao testei em 2000/2003
MsgStop( CtrlAltDel( .F. ), "Desabilitando o Ctrl+Alt+Del - Windows NT, 2k" )
MsgStop( CtrlAltDel( .T. ), "Habilitando o Ctrl+Alt+Del - Windows NT, 2k" )
ELSE //-> Windows 95/98 - Millenium Edition
Ctrl_Alt_Del( .f. )
MsgAlert( "CTRL+ALT+DEL DESLIGADO" + CRLF + "Please, press CTRL + ALT + DEL", "Desligado" )
Ctrl_Alt_Del( .t. )
MsgAlert( "CTRL+ALT+DEL LIGADO" + CRLF + "Please, press CTRL + ALT + DEL", "Ligado" )
ENDIF
Return Nil
//
//-> Comentario: Simplesmente, FANTASTICO!!!
//
//-> Complementando para Windows 95/98 Milleniu Edition
//
// Antonio Carlos Pantaglione
// Toninho@fwi.com.br
// Agosto/2001
//
//#include "fivewin.ch"
//#include "dll.ch"
//----------------------------------------------------------------------------//
//-> Modifiquei para nao ter choque com a funcao par o Windows NT(XP)
Procedure Ctrl_Alt_Del( lState )
if !lState
SysParInfo( 97, 1, 0, 0 )
else
SysParInfo( 97, 0, 0, 0 )
endif
return Nil
//----------------------------------------------------------------------------//
dll32 static function SysParInfo( uAction AS LONG, uParam AS LONG, vParam AS LONG, uWinIni AS LONG ) ;
AS LONG PASCAL FROM "SystemParametersInfoA" LIB "User32.dll"
//----------------------------------------------------------------------------//
//-> Rotina em C -> By Manuel Mercado - The Best
#pragma BEGINDUMP
#include <windows.h>
#include <stdlib.h>
#include <hbapi.h>
#define ID_STARTBUTTON 0x130 // Start button ID
#define ID_TRAY 0x12F // System tray ID
#define ID_CLOCK 0x12F // System clock ID
#define PROGRAM_MANAGER "Program Manager" // Program manager window name
#define TASKBAR "Shell_TrayWnd" // Taskbar class name
int WINAPI TaskManager_Enable_Disable( BOOL ) ;
int WINAPI StartButton_Show_Hide( BOOL ) ;
int WINAPI Desktop_Show_Hide( BOOL ) ;
int WINAPI Process_Desktop(char *, char * ) ;
int WINAPI Taskbar_Show_Hide( BOOL ) ;
int WINAPI Clock_Show_Hide( BOOL ) ;
int WINAPI AltTab_Enable_Disable( HWND, BOOL ) ;
BOOL StartProcess( char *, char * ) ;
LRESULT CALLBACK LowLevelMouseHookProc( int nCode, WORD wParam, DWORD lParam ) ;
LRESULT CALLBACK MouseHookProc( int nCode, WORD wParam, DWORD lParam ) ;
HHOOK hHook ; // Mouse hook
HINSTANCE hInst ; // Instance handle
HB_FUNC( ALTTABENABLE )
{
HWND hWnd = (HWND ) hb_parnl( 1 ) ;
BOOL bEnable = hb_parl( 2 ) ;
int iRet ;
iRet = AltTab_Enable_Disable( hWnd, bEnable ) ;
hb_retni( iRet ) ;
}
HB_FUNC( SHOWCLOCK )
{
BOOL bShow = hb_parl( 1 ) ;
int iRet ;
iRet = Clock_Show_Hide( bShow ) ;
hb_retni( iRet ) ;
}
HB_FUNC( SHOWTASKBAR )
{
BOOL bShow = hb_parl( 1 ) ;
int iRet ;
iRet = Taskbar_Show_Hide( bShow ) ;
hb_retni( iRet ) ;
}
HB_FUNC( DESKTOPPROC )
{
char* c1 = hb_parc( 1 ) ;
char* c2 = hb_parc( 2 ) ;
int iRet ;
iRet = Process_Desktop( c1, c2 ) ;
hb_retni( iRet ) ;
}
HB_FUNC( SHOWDESKTOP )
{
BOOL bShow = hb_parl( 1 ) ;
int iRet ;
iRet = Desktop_Show_Hide( bShow ) ;
hb_retni( iRet ) ;
}
HB_FUNC( STARTBUTTON )
{
BOOL bShow = hb_parl( 1 ) ;
int iRet ;
iRet = StartButton_Show_Hide( bShow ) ;
hb_retni( iRet ) ;
}
HB_FUNC( CTRLALTDEL )
{
BOOL bEnable = hb_parl( 1 ) ;
int iRet ;
iRet = TaskManager_Enable_Disable( bEnable ) ;
hb_retni( iRet ) ;
}
int WINAPI TaskManager_Enable_Disable(BOOL bEnableDisable)
{
#define KEY_DISABLETASKMGR "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"
#define VAL_DISABLETASKMGR "DisableTaskMgr"
HKEY hKey;
DWORD val;
LONG r;
if (RegOpenKey(HKEY_CURRENT_USER, KEY_DISABLETASKMGR, &hKey) != ERROR_SUCCESS)
if (RegCreateKey(HKEY_CURRENT_USER, KEY_DISABLETASKMGR, &hKey) != ERROR_SUCCESS)
return 0;
if (bEnableDisable) // Enable
{
r = RegDeleteValue(hKey, VAL_DISABLETASKMGR);
}
else // Disable
{
val = 1;
r = RegSetValueEx(hKey, VAL_DISABLETASKMGR, 0, REG_DWORD, (BYTE *)&val, sizeof(val));
}
RegCloseKey(hKey);
return (r == ERROR_SUCCESS ? 1 : 0) ;
}
int WINAPI StartButton_Show_Hide( BOOL bShowHide )
{
HWND hWnd;
hWnd = GetDlgItem( FindWindow( TASKBAR, NULL ), ID_STARTBUTTON ) ;
if ( hWnd == NULL )
return 0 ;
ShowWindow( hWnd, bShowHide ? SW_SHOW : SW_HIDE) ;
UpdateWindow( hWnd );
return 1 ;
}
int WINAPI Taskbar_Show_Hide( BOOL bShowHide )
{
HWND hWnd;
hWnd = FindWindow( TASKBAR, NULL ) ;
if ( hWnd == NULL )
return 0 ;
ShowWindow( hWnd, bShowHide ? SW_SHOW : SW_HIDE ) ;
UpdateWindow(hWnd) ;
return 1 ;
}
int WINAPI Desktop_Show_Hide( BOOL bShowHide )
{
OSVERSIONINFO osvi ;
BOOL bIsWindowsNT4SP3orLater ;
int iServicePack ;
char *p ;
// Determine the current windows version
osvi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ) ;
GetVersionEx( &osvi );
for (p = osvi.szCSDVersion; *p && ! isdigit( *p ) ; *p++ ) ;
iServicePack = atoi( p ) ;
bIsWindowsNT4SP3orLater = ( osvi.dwPlatformId == VER_PLATFORM_WIN32_NT ) &&
( ( ( osvi.dwMajorVersion == 4 ) && ( iServicePack >= 3 ) ) ||
( osvi.dwMajorVersion > 4 ) ) ;
if ( ! bShowHide )
{
if ( ! hHook )
{
hHook = SetWindowsHookEx( bIsWindowsNT4SP3orLater ? WH_MOUSE_LL : WH_MOUSE,
bIsWindowsNT4SP3orLater ? ( HOOKPROC )LowLevelMouseHookProc : ( HOOKPROC )MouseHookProc,
hInst, 0 ) ;
if ( ! hHook )
return 0 ;
}
}
else
{
UnhookWindowsHookEx(hHook);
hHook = NULL;
}
return SetWindowPos( FindWindow( NULL, PROGRAM_MANAGER ), NULL, 0, 0, 0, 0,
bShowHide ? SWP_SHOWWINDOW : SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
}
LRESULT CALLBACK LowLevelMouseHookProc( int nCode, WORD wParam, DWORD lParam )
{
PMSLLHOOKSTRUCT p = (PMSLLHOOKSTRUCT)lParam ;
HWND hWnd = WindowFromPoint( p->pt ) ;
if( nCode >= 0 )
{
if ( ( wParam == WM_LBUTTONDOWN || wParam == WM_RBUTTONDOWN ) && hWnd == GetDesktopWindow() )
{
return 1 ;
}
}
return CallNextHookEx( hHook, nCode, wParam, lParam ) ;
}
LRESULT CALLBACK MouseHookProc( int nCode, WORD wParam, DWORD lParam )
{
if( nCode >= 0 )
{
if ( wParam == WM_LBUTTONDBLCLK )
{
if ( ( ( MOUSEHOOKSTRUCT * )lParam )->hwnd == GetDesktopWindow() )
{
return 1 ;
}
}
}
return CallNextHookEx( hHook, nCode, wParam, lParam ) ;
}
int WINAPI Process_Desktop(char *szDesktopName, char *szPath )
{
HDESK hOriginalThread ;
HDESK hOriginalInput ;
HDESK hNewDesktop ;
// Save original ...
hOriginalThread = GetThreadDesktop( GetCurrentThreadId() ) ;
hOriginalInput = OpenInputDesktop( 0, FALSE, DESKTOP_SWITCHDESKTOP ) ;
// Create a new Desktop and switch to it
hNewDesktop = CreateDesktop( szDesktopName, NULL, NULL, 0, GENERIC_ALL, NULL ) ;
SetThreadDesktop( hNewDesktop ) ;
SwitchDesktop( hNewDesktop ) ;
// Execute process in new desktop
StartProcess( szDesktopName, szPath ) ;
// Restore original ...
SwitchDesktop( hOriginalInput ) ;
SetThreadDesktop( hOriginalThread ) ;
// Close the Desktop
CloseDesktop( hNewDesktop ) ;
return 0 ;
}
BOOL StartProcess( char *szDesktopName, char *szPath )
{
STARTUPINFO si ;
PROCESS_INFORMATION pi ;
// Zero these structs
ZeroMemory( &si, sizeof( si ) ) ;
si.cb = sizeof( si ) ;
si.lpTitle = szDesktopName ;
si.lpDesktop = szDesktopName ;
ZeroMemory( &pi, sizeof( pi ) ) ;
// Start the child process
if (!CreateProcess( NULL, // No module name (use command line).
szPath, // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) ) // Pointer to PROCESS_INFORMATION structure.
{
return FALSE ;
}
// Wait until process exits
WaitForSingleObject( pi.hProcess, INFINITE ) ;
// Close process and thread handles
CloseHandle( pi.hProcess ) ;
CloseHandle( pi.hThread ) ;
return TRUE ;
}
int WINAPI Clock_Show_Hide( BOOL bShowHide )
{
HWND hWnd ;
hWnd = GetDlgItem( FindWindow( TASKBAR, NULL ), ID_TRAY ) ;
hWnd = GetDlgItem( hWnd, ID_CLOCK ) ;
if ( hWnd == NULL )
return 0 ;
ShowWindow( hWnd, bShowHide ? SW_SHOW : SW_HIDE ) ;
UpdateWindow( hWnd ) ;
return 1 ;
}
int WINAPI AltTab_Enable_Disable( HWND hWnd, BOOL bEnableDisable )
{
#define m_nHotKeyID 100
if ( ! bEnableDisable )
{
if ( ! RegisterHotKey( hWnd, m_nHotKeyID+0, MOD_ALT, VK_TAB ) ) // Alt+Tab
return 0 ;
if ( ! RegisterHotKey( hWnd, m_nHotKeyID+1, MOD_ALT, VK_ESCAPE ) ) // Alt+Esc
return 0 ;
}
else
{
if ( ! UnregisterHotKey( hWnd, m_nHotKeyID + 0 ) )
return 0 ;
if ( ! UnregisterHotKey( hWnd, m_nHotKeyID + 1 ) )
return 0 ;
}
return 1 ;
}
#pragma ENDDUMP
/*
Saludos
Manuel Mercado
*/Olá,
Ao compilar os erros são gerados:
Type: C >>>xhb.exe -o"teclado.c" -m -n -p -q -gc0 -I"C:\fwh\include" -I"C:\xhb\include" -I"C:\xhb\include\w32" "teclado.prg"<<<xHarbour Compiler build 1.1.0 (SimpLex) (Rev. 6177)Copyright 1999-2008, http://www.xharbour.org http://www.harbour-project.org/Generating object output to 'teclado.obj'...teclado.prg(210): error: Undeclared identifier 'WH_MOUSE_LL'.teclado.prg(227): error: Undeclared identifier 'PMSLLHOOKSTRUCT'.teclado.prg(227): error: Syntax error; found 'p' expecting ';'.teclado.prg(227): error: Undeclared identifier 'p'.teclado.prg(227): error: Syntax error; found 'lParam' expecting ';'.teclado.prg(228): error: Left operand of -> has incompatible type 'int'.teclado.prg(228): error: Type error in argument 1 to a function; found 'int' expected 'struct tagPOINT'.teclado.prg(261): warning: Missing prototype for 'CreateDesktopA'.teclado.prg(261): warning: Conversion from 'struct HDESK__ *' to 'int' is undefined.Type: C >>>Couldn't build: teclado.obj<<<
O que pode ser ?
Obrigado,
Rossine.