|
I have an application that is a system service (Windows 2000). Among other things, I want it to set a system hook to trap WH_KEYBOARD_LL messages. However, my message handler does not seem to get called. The same code works fine when it is not running as a system service. Is it impossible for a service to set such hooks?
Any help is greatly appreciated!
|
|
|
|
|
Is your service logging in as the system account? If so, change it to log in as you and see if it then works. If that fixes it, then the reason you're not getting called when logged in as the system is a security restriction.
--Mike--
http://home.inreach.com/mdunn/
Sometimes, arming yourself with a big pointy stake just won't do you any good.
|
|
|
|
|
Hi,
I am trying to link to a dll at runtime. My DLL is definitely okay, it has a functon :
_declspec(dllexport) int increment(int val)
The client to the DLL executes the following code:
typedef int(*lpf_increment)(int);
HINSTANCE plugin;
plugin = LoadLibrary("c:\\plugin.dll");
if (plugin != NULL)
{
lpf_increment testcall;
testcall = (lpf_increment) GetProcAddress(plugin, _T("increment"));
int val=99;
int res = (testcall)(val);
char dump[60];
wsprintf(dump,"%i",res);
MessageBox("dump");
}
The GetProcAddress returns null, anyone any clues what's wrong?
Cheers
Richard
|
|
|
|
|
Run Dependency Viewer on your DLL - chances are the exported function is name-mangled, and not actually exported as "increment".
--Mike--
http://home.inreach.com/mdunn/
Sometimes, arming yourself with a big pointy stake just won't do you any good.
|
|
|
|
|
make sure that the function is being export correctly.
if it is C++ the export name will be name-mangaled
to view the exports from any dll use the dumpbin or depends utility from VC++
dumpbin /exports mydll.dll | more
When you build your DLL put this in the header file
this assumes that your Function/method to be exported is called int foo(int);
// exporting dll header file
#ifdef __cplusplus
#define EXTERN_C extern "C"
#else
#define EXTERN_C
#endif
EXTERN_C int foo(int);
|
|
|
|
|
make sure that the function is being export correctly.
if it is C++ the export name will be name-mangaled
to view the exports from any dll use the dumpbin or depends utility from VC++
dumpbin /exports mydll.dll | more
When you build your DLL put this in the header file
this assumes that your Function/method to be exported is called int foo(int);
// exporting dll header file
#ifdef __cplusplus
#define EXTERN_C extern "C"
#else
#define EXTERN_C
#endif
EXTERN_C __declspec(dllexport) int foo(int);
|
|
|
|
|
Thanks That Was Really Appreciated! Everythings clear now.
|
|
|
|
|
I try to acted this func from my main dialog in dialog project.
but I dont know what to give to its first parameter.
please help !
|
|
|
|
|
try:
this->m_hWnd
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
GetSafeHwnd() is the proper way to do this.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
I've found that using CDC.SelectObject() on a locally created object causes a massive drain on system resources, especially if you use it during an intensive screen update (OnDraw of a CScrollView, for example).
CScrollView::drawSomething() //called from OnDraw
{
CClientDC cdc(this);
CPen lightBluePen(PS_SOLID, 1, 0x00FFFFCC);
cdc.SelectObject(lightBluePen);
// blah blah
}
Apart from declaring lightBluePen as a modular variable which seems to stop this, is there a better way, ie some way of freeing this resource?
Thanks in advance!
|
|
|
|
|
Well, this was a problem I had, also, a time ago and I found the solution in this forum:
I have this in a header file:
class CSaveDC {
public:
CSaveDC(CDC * dc) { sdc = dc; saved = dc->SaveDC(); }
virtual ~CSaveDC() { sdc->RestoreDC(saved); }
protected:
CDC * sdc;
int saved;
};
And in the code file in my OnDraw function:
CPen m_pPincelR, m_pPincelN, m_pPincelA, m_pPincelM, m_pPincelV;
CFont m_pLetraP, m_pLetraG;
m_pLetraG.CreateFont(16,0,0,0,FW_SEMIBOLD,FALSE,FALSE,FALSE,
DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
18,"Times New Roman");
m_pLetraP.CreateFont(15,0,0,0,FW_NORMAL,FALSE,FALSE,FALSE,
DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
18,"Times New Roman");
m_pPincelR.CreatePen(PS_SOLID,2,RGB(255,0,0));
m_pPincelN.CreatePen(PS_SOLID,2,RGB(255,96,0));
m_pPincelA.CreatePen(PS_SOLID,2,RGB(0,255,255));
m_pPincelM.CreatePen(PS_SOLID,2,RGB(255,0,255));
m_pPincelV.CreatePen(PS_SOLID,2,RGB(0,255,0));
{
CSaveDC sdc (pDC);
pDC->SelectObject(m_pLetraG);
pDC->TextOut(25,-2,actual);
pDC->SelectObject(m_pLetraP);
..more TextOut...
pDC->SelectObject(m_pPincelR);
...drawing functions...
pDC->SelectObject(m_pPincelN);
...drawing functions...
pDC->SelectObject(m_pPincelA);
...drawing functions...
pDC->SelectObject(m_pPincelM);
...drawing functions...
pDC->SelectObject(m_pPincelV);
...drawing functions...
}
... OnDraw follows...
And it works fine, I've tried to redraw many times and there is not memory consumption.
The { and } are very important, when it finishes, the selections are automatic deleted.
|
|
|
|
|
Its just a guess, but could it be because your not releasing the object you select into the DC(the blue pen) when your done.
I think it should look more like this;
CScrollView::drawSomething()
{ <br />
<br />
CClientDC cdc(this); <br />
<br />
CPen lightBluePen(PS_SOLID, 1, 0x00FFFFCC); <br />
<br />
CPen * pOldPen = cdc.SelectObject(lightBluePen); <br />
<br />
<br />
cdc.SelectObject(pOldPen); <br />
<br />
}
Just my 2 cents.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
How would i find the max index of an array? For example:
long myarray[10];
the function should return 10
any ideas?
|
|
|
|
|
You can try this:
int maxArray = sizeof(myarray)/sizeof(long);
later
...er - well I guess the max index would be that - 1 ...
|
|
|
|
|
Why don't you use STL vector instead of "plain" array?
I vote pro drink
|
|
|
|
|
How do I sort DaoRecordsets on a numeric field?
m_pSet->m_strSort="[My long Field]"; gives a sort, but it appears to alpha-numeric, not numeric.
All help apperciated!
Richard
|
|
|
|
|
The problem is that m_strSort only returns the name of the fields or fields that were includes in the Order By if you opened the recordset with a Query.
For example if you open de recordset with some like this:
Select * from table Order by field1, field2
The m_strSort will return you 'field1, field2'.
For make a order in a table you will need to use CDaoRecordset::SetCurrentIndex but the problem is that the field must be a index.
Did you Understand?
Cheers.
Carlos Antollini.
|
|
|
|
|
Suppose I have 2 pens created like these:
CPen m_pPenR, m_pPenN;
m_pPenR.CreatePen(PS_SOLID,3,RGB(255,0,0));
m_pPenN.CreatePen(PS_SOLID,3,RGB(255,150,0));
...
more code
...
pDC->SelectObject(m_pPenR);
myGraphic (a,b,pDC);
...
more code
...
pDC->SelectObject(m_pPenN);
myGraphic (c,d,pDC);
...
And into myGraphic(...) function I want to use the selected pens, drawing some lines but changing sometimes one or two of pens parameters (for example I want it with PS_DOT and width=1pixel, but remaining the color) and sometimes don´t.
How can I do it?
Thank you.
|
|
|
|
|
Hi all,
Does anyone know how to transfer the unsigned char to char AND how to transfer the char to unsigned char???
I know it is stupid......;P
Thanks
|
|
|
|
|
Do you just want to assign between two variables? Then use casts:
signed char ch = -1;
unsigned char uch = (unsigned char) ch;
--Mike--
http://home.inreach.com/mdunn/
Sometimes, arming yourself with a big pointy stake just won't do you any good.
|
|
|
|
|
Hi. I have a big problem about my application like a Windows Commander. When I have folder and folder has too many files, when I double-click to folder, I must wait about 10 and more seconds to open a folder. I need any optimization idea to find file operation - need file parameters and file icon (I used two methods - use ::FindFirstFile, ::FileNextFile and second method is use CFileFind). Thanks Ivan
|
|
|
|
|
I love this Place. I came to Codeproject.com with this question and here it is!
Thanx alot!
Enzi
|
|
|
|
|
Everybody's seen default buttons (that click when enter is pressed) in dialog boxes, but now I have a toolbar button that I would like to act this way. There is an edit ctrl in the toolbar, and when the user types a value they should be able to press enter if they're too lazy to click on the button. Ideas?
thanks,
Jake
|
|
|
|
|
If you are fairly certain this can not be done, can you let me know, because my boss has been bugging me about it for over a week I've told him I can't do it, and I need some backup from you guys. thanks,
Jake
|
|
|
|
|