forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Built a DLL MS C++ 6.0

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced VDS 6 Source Code
View previous topic :: View next topic  
Author Message
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 767
Location: Eastman, GA

PostPosted: Sat Jul 04, 2026 7:48 pm    Post subject: Built a DLL MS C++ 6.0 Reply with quote

Turns off Alt+Tab and Alt+Esc.

Code:

LOADLIB vds_remap.dll
%%SUCCESS = @LIB(vds_remap.dll, StartAltTabHook, int:, void:)
wait event
%%VOID = @LIB(vds_remap.dll, StopAltTabHook, void:, void:)
FREELIB vds_remap.dll


Code:

#include "stdafx.h"
#include <windows.h>

// --- VC6 compatibility definitions ---
#ifndef WH_KEYBOARD_LL
#define WH_KEYBOARD_LL 13
#endif

typedef struct tagKBDLLHOOKSTRUCT {
    DWORD vkCode;
    DWORD scanCode;
    DWORD flags;
    DWORD time;
    DWORD dwExtraInfo;
} KBDLLHOOKSTRUCT, *PKBDLLHOOKSTRUCT;
// -------------------------------------

extern "C" __declspec(dllexport) int StartAltTabHook();
extern "C" __declspec(dllexport) void StopAltTabHook();

HHOOK hKeyboardHook = NULL;

LRESULT CALLBACK KeyboardHookCallback(int nCode, WPARAM wParam, LPARAM lParam) {
    if (nCode == HC_ACTION) {
        KBDLLHOOKSTRUCT* pKeyBoard = (KBDLLHOOKSTRUCT*)lParam;
       
        // Check if Alt (VK_MENU) is held down
        if (GetAsyncKeyState(VK_MENU) & 0x8000) {
           
            // Intercept Alt + Tab OR Alt + Escape
            if (pKeyBoard->vkCode == VK_TAB || pKeyBoard->vkCode == VK_ESCAPE) {
                return 1; // Drop the keystroke entirely
            }
        }
    }
    return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam);
}

// Called by VDS to turn ON the block
int StartAltTabHook() {
    if (hKeyboardHook == NULL) {
        hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardHookCallback, GetModuleHandle(NULL), 0);
    }
    return (hKeyboardHook != NULL) ? 1 : 0;
}

// Called by VDS to turn OFF the block
void StopAltTabHook() {
    if (hKeyboardHook != NULL) {
        UnhookWindowsHookEx(hKeyboardHook);
        hKeyboardHook = NULL;
    }
}
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced VDS 6 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group