Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help Creating an FLL
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Title:
Help Creating an FLL
Miscellaneous
Thread ID:
00695530
Message ID:
00695530
Views:
86
I have never created an FLL, but this code was in a previous message here in the UT, for create an FLL to detect idle item. I have attempted to compile in in MSVS c++ 6.0. But I get 7 errors and 1 warning. I'm hoping someone with real knowledge (I don't have it) of C++ could compile this into an FLL for me.

Thanks in advance. The code is in the first block, followed by the errors I received in the second block:
// idle.cpp
// IDLE TIME HOOKS -- Copyright 2001 Visual Records, Inc. www.visualrecords.com


#include <pro_ext.h>
#include < windows.h >
#include < stdio.h >


// HOOK ROUTINES--
FILETIME ftHookTime;
HHOOK hKeyboardHook, hMouseHook;
POINT ptHook = {0, 0};

LRESULT CALLBACK KeyboardProc(int code, WPARAM wParam, LPARAM lParam)
{
	// RESET TIMER
	GetSystemTimeAsFileTime(&ftHookTime);

	// THUNK TO NEXT HOOK
	return CallNextHookEx(hKeyboardHook, code, wParam, lParam);
}

LRESULT CALLBACK MouseProc(int code, WPARAM wParam, LPARAM lParam)
{
	MOUSEHOOKSTRUCT* pmhs;
	pmhs = reinterpret_cast<MOUSEHOOKSTRUCT*>(lParam);
	if(wParam == WM_MOUSEMOVE)
	{
		if(pmhs->pt.x != ptHook.x || pmhs->pt.y != ptHook.y)
		{
			ptHook = pmhs->pt;
			// RESET TIMER
			GetSystemTimeAsFileTime(&ftHookTime);
		}
	} else
		GetSystemTimeAsFileTime(&ftHookTime);


	// THUNK TO NEXT HOOK
	return CallNextHookEx(hMouseHook, code, wParam, lParam);
}

void InstallHooks(ParamBlk *parm) // bool InstallHooks(lbInstall)
{
	if(p0.val.ev_length)
	{
		// FIRST UNHOOK ANY PRIOR HOOKS
		if(hKeyboardHook) UnhookWindowsHookEx(hKeyboardHook);
		if(hMouseHook) UnhookWindowsHookEx(hMouseHook);

		// INSTALL HOOKS
		hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc,
			0, GetCurrentThreadId());
		if(hKeyboardHook == 0)
		{
			_RetLogical(false);
			return;
		}

		hMouseHook = SetWindowsHookEx(WH_MOUSE, MouseProc,
			0, GetCurrentThreadId());
		if(hMouseHook == 0)
		{
			// CLEANUP KEYBOARD HOOK
			UnhookWindowsHookEx(hKeyboardHook);
			hKeyboardHook = 0;
			_RetLogical(false);
			return;
		}

		// SET HOOK TIME TO CURRENT TIME
		GetSystemTimeAsFileTime(&ftHookTime);

		// SUCCESS
		_RetLogical(true);
		return;
	} 
	else
	{
		// UNINSTALL HOOKS
		if(hKeyboardHook) {
			UnhookWindowsHookEx(hKeyboardHook);
			hKeyboardHook = 0;
		}
		if(hMouseHook) {
			UnhookWindowsHookEx(hMouseHook);
			hMouseHook = 0;
		}

		// SUCCESS
		_RetLogical(true);
	}
}

void ResetHookTime(ParamBlk *parm) // void ResetHookTime()
{
	// RESET TIMER
	GetSystemTimeAsFileTime(&ftHookTime);

	// SUCCESS
	_RetLogical(true);
	return;
}

void GetHookTime(ParamBlk *parm) // currency GetHookTime()
{
	// PROCESS 64BIT INT
	LARGE_INTEGER time;
	time.LowPart = ftHookTime.dwLowDateTime;
	time.HighPart = ftHookTime.dwHighDateTime;

	// RETURN TIME AS CURRENCY
	_RetCurrency(time, 10);
}

void GetCurrentTime(ParamBlk *parm) // currency GetCurrentTime()
{
	// GET TIME
	FILETIME ft;
	GetSystemTimeAsFileTime(&ft);

	// PROCESS 64BIT INT
	LARGE_INTEGER time;
	time.LowPart = ft.dwLowDateTime;
	time.HighPart = ft.dwHighDateTime;

	// RETURN TIME AS CURRENCY
	_RetCurrency(time, 10);
}

// UNLOAD EVENT
void Unloadlib(ParamBlk *parm)
{
	// UNHOOK ALL HOOKS
	if(hKeyboardHook) UnhookWindowsHookEx(hKeyboardHook);
	if(hMouseHook) UnhookWindowsHookEx(hMouseHook);
	hKeyboardHook = 0;
	hMouseHook = 0;
}

FoxInfo libFoxInfo[] = {
	{"GETCURRENTTIME", (FPFI) GetCurrentTime, 0, ""},
	{"INSTALLHOOKS", (FPFI) InstallHooks, 1, "L"},
	{"RESETHOOKTIME", (FPFI) ResetHookTime, 0, ""},
	{"GETHOOKTIME", (FPFI) GetHookTime, 0, ""},
	{"UNLOADLIB", (FPFI) Unloadlib, CALLONUNLOAD, ""},
};

extern "C" {
    // the FoxTable structure
    FoxTable _FoxTable = {
        (FoxTable  *) 0, sizeof(libFoxInfo)/sizeof(FoxInfo), libFoxInfo
    };
}
Error Messages
--------------------Configuration: idle - Win32 Debug--------------------
Compiling...
idle.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\idle\idle.cpp(46) : error C2065: 'p0' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\idle\idle.cpp(46) : error C2228: left of '.val' must have class/struct/union type
C:\Program Files\Microsoft Visual Studio\MyProjects\idle\idle.cpp(46) : error C2228: left of '.ev_length' must have class/struct/union type
C:\Program Files\Microsoft Visual Studio\MyProjects\idle\idle.cpp(117) : warning C4002: too many actual parameters for macro 'GetCurrentTime'
C:\Program Files\Microsoft Visual Studio\MyProjects\idle\idle.cpp(118) : error C2556: 'void __fastcall __fastcall GetTickCount(void)' : overloaded function differs only by return type from 'unsigned long __stdcall GetTickCount(void)'
        c:\program files\microsoft visual studio\vc98\include\winbase.h(2968) : see declaration of 'GetTickCount'
C:\Program Files\Microsoft Visual Studio\MyProjects\idle\idle.cpp(118) : error C2373: 'GetTickCount' : redefinition; different type modifiers
        c:\program files\microsoft visual studio\vc98\include\winbase.h(2968) : see declaration of 'GetTickCount'
C:\Program Files\Microsoft Visual Studio\MyProjects\idle\idle.cpp(118) : error C2491: 'GetTickCount' : definition of dllimport function not allowed
C:\Program Files\Microsoft Visual Studio\MyProjects\idle\idle.cpp(143) : error C2065: 'GetCurrentTime' : undeclared identifier
Error executing cl.exe.

idle.obj - 7 error(s), 1 warning(s)
Next
Reply
Map
View

Click here to load this message in the networking platform