|
You need to save your values(list) that when you run your program this values insert to your list
you can use registry or file or another ways.
whitesky
|
|
|
|
|
In my dialog based MFC application, I initiate windows hook as follows
HHOOK TheHook; <br />
LRESULT CALLBACK ShellProc( int nCode,<br />
WPARAM wParam,<br />
LPARAM lParam<br />
);<br />
<br />
BOOL CTmphookDlg::OnInitDialog()<br />
{<br />
..<br />
..<br />
HINSTANCE ppI = AfxGetInstanceHandle();<br />
TheHook=SetWindowsHookEx(WH_SHELL, ShellProc, ppI,0);<br />
..<br />
..<br />
}<br />
<br />
LRESULT CALLBACK ShellProc( int nCode,<br />
WPARAM wParam,<br />
LPARAM lParam<br />
)<br />
{<br />
<br />
if(nCode==HSHELL_WINDOWCREATED)<br />
{<br />
HWND hWnd = (HWND)(wParam);<br />
char szClassName[256];<br />
GetClassName(hWnd, szClassName, sizeof(szClassName));<br />
AfxMessageBox(szClassName);<br />
}<br />
<br />
return CallNextHookEx(TheHook, nCode, wParam, lParam);<br />
}
What I want is when any window (other applications) is created on the operating system.. it should flash a message telling its class name.
But this code only shows its class name initially when the dialog is being created. I tried to open notepad or other windows of other applications, it didnt flash any message.
Why is that so.? What to do to get this?
Row
|
|
|
|
|
You're calling SetWindowsHookEx with the dwThreadId set to zero and the hMod set the the .EXE module handle. If you look at the documentation you'll see the following:
dwThreadId
[in] Specifies the identifier of the thread with which the hook procedure is to be associated.
If this parameter is zero, the hook procedure is associated with all existing threads running
in the same desktop as the calling thread.
All global hook functions must be in libraries.
In short you're you're using a global hook and global hook procudures must be in a DLL (that's how it gets into the address space of another process; the other processes loads it). You're hook procudure is in the MFC .EXE.
Steve
|
|
|
|
|
|
|
WH_KEYBOARD_LL and WH_MOUSE_LL are special cases. The following is a quote from MSDN:
"However, the WH_KEYBOARD_LL hook is not injected into another process. Instead, the context switches back to the process that installed the hook and it is called in its original context. Then the context switches back to the application that generated the event."
This is why the example he gave works; it has nothing to do with his Microsoft conspiracy theories. My advice is to follow the rules and ignore that article.
Steve
|
|
|
|
|
You are right steve.
Regards,
FarPointer
Blog:http://farpointer.blogspot.com/
|
|
|
|
|
Hello,everyone!I want to use ADO to connect MS SQL Server which locates in the public Internet,and the Client locates in a Local Area NetWork.How should I code?Who can give me some advices?And the example code is the better,Thanks!
|
|
|
|
|
hello anyone!
how do i call an api function in __asm block?(in VC++ project)
can some one give me a simple sample for understanding?
thank.
Zo.Naderi-Iran
|
|
|
|
|
zoncpp25 wrote: how do i call an api function in __asm block?(in VC++ project)
see here[^]
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Hai all,
I am not able to understand how to use ADO.net in VC++.net. If possible, please guide me.
Ravindra
|
|
|
|
|
See Here[^] and Here[^] maybe it is some helpful to you
whitesky
|
|
|
|
|
That's a pretty broad question. Have you read the MSDN help ? What are you tring to do ? How far have you got ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
hi all. im new here and to windows programming. actually i started out to learn Visual C++. the book i follow first goes thru windows programming basics in C++. i tried out the first prog in the book and got stuck. im using VC 6.0. the prog is here:
#include<windows.h>
int_stdcall WinMain(HINSTANCE hinstance,
HINSTANCE hPrevinstance,
LPSTR lpszCmdline,
int nCmdShow)
{
MessageBox(0, "Hello!", "Title", 0);
return (0);
}
though it is simple, i get error messages that i cannot eliminate. please help.
the errors are:
E:\Program Files\Microsoft Visual Studio\sample1\sample1.cpp(3) : error C2146: syntax error : missing ';' before identifier 'WinMain'
E:\Program Files\Microsoft Visual Studio\sample1\sample1.cpp(3) : error C2501: 'int_stdcall' : missing storage-class or type specifiers
E:\Program Files\Microsoft Visual Studio\sample1\sample1.cpp(3) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
well i dunnot know if this is the right place to post my problem, but i did not find another better place for it. if this is not the right place then tell me.
thx 2 all 4 any hlp.
-- modified at 6:41 Saturday 17th June, 2006
|
|
|
|
|
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
::MessageBox (NULL,"Hello","1",MB_OK);
return 0;
}
In your code // there should be two underscore signs before stdcall and a space between int and __stdcall
int __stdcall WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
::MessageBox (NULL,"Hello","1",MB_OK);
return 0;
}
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
-- modified at 6:51 Saturday 17th June, 2006
|
|
|
|
|
thanks _AnShUmAn_. i tried ur suggestion. it worked.
|
|
|
|
|
See Here[^] maybe it is some helpful to you
whitesky
|
|
|
|
|
iwrote the file by folowing code
CFile time;
time.Open("c:\\abc.txt",CFile::modeCreate|CFile::modeReadWrite );
CString str;
str.Format ("%d",i);
time.Write(str,strlen(str));
time.Close();
UpdateData(FALSE);
So please tell how to read this and how to convert to int.
|
|
|
|
|
For reading from a file directly in CString use
CStdioFile time;
time.Open("c:\\abc.txt",CFile::modeRead);
CString str;
time.ReadString (str);
int i=atoi(str);
time.Close ();
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
thank u very much,
it's working and my project is completed thank u ,
sree.
|
|
|
|
|
|
Again a query 'query'!!
Am i using the Delete query prop here?rather can i use it lik dis?(Hvalue is of number type in Access db)
CString hv;
_Commandptr m_pCommand;
m_pCommand=NULL;
m_pCommand.CreateInstance(__uuidof(Command));
CString strSql = _T("DELETE FROM wcs WHERE Hvalue='") +hv+ _T("')");
m_pCommand->CommandText = _bstr_t(strSql);
m_pCommand->CommandType=adCmdText;
m_pCommand->ActiveConnection = m_pConnection;
_variant_t vRecords1;
m_pCommand->Execute(&vRecords1,NULL,adCmdText);
Using the foll code..How do i retrieve the min value?how do i get to know to which record(in Access db) contains the result??(Hvalue is a number)
_Commandptr m_pCommand;
m_pCommand=NULL;
m_pCommand.CreateInstance(__uuidof(Command));
CString strSql1 = _T("SELECT MIN(Hvalue) FROM wcs");
m_pCommand->CommandText = _bstr_t(strSql1);
m_pCommand->CommandType=adCmdText;
m_pCommand->ActiveConnection = m_pConnection;
_variant_t vRecords;
m_pCommand->Execute(&vRecords,NULL,adCmdText);
|
|
|
|
|
shuchigo_jane wrote: select and delete query
Humm ... Combination of previous posts.
select[^]
delete[^]
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
v v desperate 4 an ans!!
|
|
|
|
|
shuchigo_jane wrote:
CString strSql = _T("DELETE FROM wcs WHERE Hvalue='") +hv+ _T("')");
Try strSql.Format(...) instead of direct assigning..
shuchigo_jane wrote: Using the foll code..How do i retrieve the min value?how do i get to know to which record(in Access db) contains the result??(Hvalue is a number)
_variant_t vRecords;
m_pCommand->Execute(&vRecords,NULL,adCmdText);
I think vRecords returns the results ,right??
Access the count of min as vRecords.iVal if result returning as integer.
Knock out 't' from can't,
You can if you think you can
|
|
|
|