|
CreateService();
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
A small update...
Something like:
schService = CreateService(
schSCManager,
TEXT(SZSERVICENAME),
TEXT(SZSERVICEDISPLAYNAME),
SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_DEMAND_START,
SERVICE_ERROR_NORMAL,
szPath,
NULL,
NULL,
TEXT(SZDEPENDENCIES),
NULL,
NULL);
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Under VC++, I made a DLL as -Win32 Dinamic Link-. It has only one ".C" file containing the DLLMain two Function and the callback function. The first function loads the callback function and the second function unloads the callback function. Here is how the callback is loaded:
HHOOK hhGetMsg;
HINSTANCE hInstance;
LRESULT CALLBACK GetMsg (int iCode, WPARAM wParam, LPARAM lParam);
{
hhGetMsg = SetWindowsHookEx (WH_GETMESSAGE, (HHOKPROC) GetMsg, hInstance, 0);
}
with the GetMsg sending messages to a window everytime a message pops-up. There are no filters so all messages are SUPPOSEDLY "trapped". I used SendMessage to avoid a mess. Also calls CallNextHookEx.
I have looked at other codes that SUCCESSFULLY loaded a system-wide hook and My code are basically Identical. But my hook only monitors the APP/.EXE that loads it! I don't get it! The DLL and its functions are loaded from the APP/.EXE using LoadLibrary and GetProcAddress.
Need help! Thanks in advance.
|
|
|
|
|
I guess your problem is don't put any global data in a shared section, all data you use in your hook function must be placed in a shared section so it is same as multiple DLL instances.
here is a my snippet of code...
#pragma data_seg(".shared")
HHOOK g_hMouseHook = NULL;
HINSTANCE g_hInstance = NULL;
MOUSEHOOKSTRUCT* g_pMHS = NULL;
HWND g_hLastWnd = NULL;
UINT g_nLastMessage = 0;
UINT g_nLastHitTestCode = 0;
#pragma data_seg()
#pragma comment(linker, "/section:.shared,rws")
look at MSDN for more about shared section.
|
|
|
|
|
Many Thanks
|
|
|
|
|
I actually just created a system-wide keyboard hook. It was my very first time, and I managed to do it without any knowlegde of what you're talking about. I don't even understand what it means Anyway, I didn't use any #pragma preprocessor commands or anything special. If you want to check out my source, just tell me...
Sprudling
|
|
|
|
|
I need to do something when a file is opened using the menu of a SDI application.
I tried handling the ID_FILE_OPEN message, but that removes the open dialog. I still want it to happen, but I need to do other things.
Where do I do this?
Thank You
XP
|
|
|
|
|
The document recieves a OnFileOpen message, you can do it there.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
I was wondering how many people base their error trapping on try and catch? I read in "Game Programming Gems" that exception handling was "expensive" and I wanted to know if anyone has felt this impact? I am writing a multi-client nonblocking telnet server app and speed can turn into an issue. Would I be better off to do a tradition bool or int error returns? Any input would rock!
----
Xian
|
|
|
|
|
Game programming and "normal app" programming are entirely different animals. Games are all about speed, speed, and more speed. When you write something like a Telnet app, most of your cycles will be spent waiting for the user to do something, or waiting for data to arrive via the connection.
I personally use return values for errors. It's what I'm used to and I would gain nothing by using exceptions. MHO of course.
--Mike--
http://home.inreach.com/mdunn/
#include "witty_sig.h"
your with and
|
|
|
|
|
try/catch is not expensive if it's used for unrecoverable errors. At that point you're exiting from the game anyhow. Unreal used exception handling and it's a high performance FPS. try/catch is only expensive if it's used to catch normally occuring errors.
Todd Smith
|
|
|
|
|
No text
----
Xian
|
|
|
|
|
In addition to the other replies, the "expense" of exception handling greatly depends on how it is (mis)used.
For example, wrapping your entire application's code with a single try/catch is not too expensive. But wrapping every single call to "recv(...)" or "send(...)" or every time you process a window messages (if you have a message pump) might be.
Peace!
-=- James.
|
|
|
|
|
Yeah, my main function looks kinda like this :
XGameObj * pGameObj = new XGameObj();
try
{
pGameObj->initGame();
pGameObj->startListener();
pGameObj->gameLoop();
}
catch( const char * pszError )
{
}
My support functions in my Socket handler throw back errors and if they are
bad then I throw them back to the main loop. Other than that I am not doing much with it. I only throw back to the beginning for irrecoverable errors. I hope this is the "proper" way of doing it. I pretty much just figured it out on my own. I dont try/catch every send and receive, plus this is a console app, so no windows pumps! Every heartbeat the events are fired based on time. Like connections are checked and messages are checked every beat, while updates to the queues may occur every 1 real second, etc. I am pretty much just making it up as I go along
Peace.
|
|
|
|
|
> Yeah, my main function looks kinda like this : [...]
I assume you know this, but without a "catch all" handler, you will not catch things like dereferencing a NULL pointer, or other exceptions.
-=- James.
|
|
|
|
|
I assume you know this, but without a "catch all" handler, you will not catch things like dereferencing a NULL pointer, or other exceptions.
I assume you know this, but SEGV is nothing the C++ exception mechanism would usually handle. It's a Microsoft extension. A C++ exception handler (in the context of the ISO C++ standard) handles C++ exceptions. No more, no less.
/Mike
|
|
|
|
|
The astute reader will notice that I did not (nor did anyone else, for that matter) specifically mention "Segmentation Violation", or anything else even close to Unix.
-=- James.
|
|
|
|
|
I always use CDatabase and CRecordset when I am doing windows programming. I was wondering if there is an ADO class that you can use with MFC and whether there is a simple example of it somewhere?
thanks
|
|
|
|
|
There's one here AFAIK. I just #import and use it directly myself.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
There might be a lot of wrapper classes for ADO's raw interfaces.
but it's so easy to use ado with three or more interfaces - _RecordsetPtr, _ConnectionPtr, _CommandPtr. Just make a SQL query string And open recordset , that's all.
|
|
|
|
|
I am programatically changing the font smoothing type in WindowsXP. In WindowsXP there are there settings: no font smoothing, standard font smoothing, and ClearType font smoothing. After diggin into MSDN I found that font smoothing can be set by calling
SystemParametersInfo(SPI_SETFONTSMOOTHING, TRUE, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
I can enable font smoothing, disable font smoothing, and set font smoothing to ClearType.
I can not change the font smoothing mode to standard or change the smoothing contrast. I followed exactly as MSDN instructs but they fail. The MSDN article can be found here.
[edit]
Using GetLastError() it gives the error "The parameter is incorrect."
I am using
SystemParametersInfo(SPI_SETFONTSMOOTHINGCONTRAST, 1600, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
copied staight from the MSDN article and I'm using the latest PlaformSDK.
[/edit]
And thanks goes out to Nish for steering me in the right direction. The SPIF_SENDCHANGE parameter actually tells it to send a WM_SETTINGCHANGE message.
Joshua
|
|
|
|
|
I am writing a program that was working fine until I added one more variable. Instead of 2 char* I now have three. Each char* is allocated using the new operator and a size of 524,920. Everything works fine until I put in that third variable. Now I get a dynamic memory overrun error, even when I don't touch the data.
Any Ideas?
Thanks in advance,
Clint
|
|
|
|
|
I've read there is a 64k dynamic allocation limit on arrays.
----
Xian
|
|
|
|
|
I'm not sure if this coincide with what you need...
I needed a buffer for file manipulation. The "new" seemed to be limited to 64k of memory. A work around this uses structures. Declare a structure with elements (in my case, BYTE) as array of size 0xff (65,535). If you need more than 64k of memory, declare more array of BYTE's. In order to use it, declare a variable of the structure and a pointer to BYTE. Then point the pointer to the first element of the structure, and voila!, you have a buffer array of more than 64k! Just use the pointer to access the buffer. (elements declared in a structure are allocated continously).
Note: if elements are of size 0xff each, I noticed that one can not have more than 16 elements. Ofcourse, I might be wrong.
typedef struct BUFFER {
BYTE Buffer0 [0xff];
BYTE Buffer1 [0xff];
...
BYTE BufferN [0xff];
} BUFFER;
void Some_Function ()
{
BUFFER Buffer;
BYTE *pBuffer;
pBuffer = Buffer.Buffer0;
memset (pBuffer, 0, <size_of_the total="" array="" of="" buffer="">);
...
}
|
|
|
|
|
Just vondering why you don't use malloc() instead.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|