|
Hi, guys,
is there a way to intercept mouse clicks or keystrokes when an application runs in the background (a window does not have a focus) without using global Win32 hooks?
Thanks a lot.
|
|
|
|
|
Write a Keyboard Filter Driver
Write a Mouse Driver Filter
I've seen better runs in my shorts! - Patches O'Houlihan
|
|
|
|
|
I have not thought of the drivers. Thanks a lot.
|
|
|
|
|
I have 16 project that I only have the source code for that I would like to put into a Solution. I have been able to create a solution with all the 16 project directories, but when I view this in the Solution Config it only show the Project for which the Solution was create. Thus I can't compile and run each of the 16 project by them selves.
Kind of looks like this:
Solution A
StartServer
.C/.Cpp/.h
ShutdownServer
.C/.Cpp/.h
.
.
.
RunReport
.C/.Cpp/.h
Directory file structure is:
c:\Solution A\
c:\Solution A\StartServer\
c:\Solution A\ShutdownServer\
...
c:\Solution A\RunReport
Config file only shows Solution A thus it compile all 16 everytime...
I should be able to select on of the projects and compile/run it.
Any help would be much appriciated.
Jim
|
|
|
|
|
To do this you either have to right click on the project in the Solution Explorer window and select Project Only/Build Only... from the menu
Or you can select the project you want to build as the startup project, and under the build menu select the second set of build commands, the ones that have the project name in the menu item.
Selecting Build Solution (Ctrl+B) will build the entire solution which is all the project.
Also check the dependency of the projects to make sure they are correct. (Menu Project/Project Dependencies.
AliR.
Visual C++ MVP
|
|
|
|
|
I'm trying to load a disk file into memory and the program crashes when it tries to exit. As far as I can tell the file never got loaded. The compiler dosen't catch the error, but the debugger did point to this part of ios.cpp when it crashed, the line has a smilie next to it:
<br />
ios_base::~ios_base()<br />
{
if (0 < _Stdstr && 0 < --stdopens[_Stdstr]):mad:<br />
return;<br />
_Tidy();<br />
_DELETE_CRT(_Ploc);<br />
}
My specification file code:
#include "DnD_Common_Defs.h"<br />
#include "windows.h"<br />
#include <iostream><br />
#include <string><br />
#include <fstream><br />
<br />
using namespace std;<br />
<br />
class DataLoading<br />
{<br />
public:<br />
DataLoading();
RaceDataType ReturnRaceData(int RaceToReturn);<br />
protected:<br />
bool LoadUpRaceData(string FileName);
private:<br />
int NumBaseRaces;<br />
ifstream inData;
RaceDataType BaseRaces[6]; <br />
};
Relevant parts of implementation file code:
#include <iostream><br />
#include <fstream><br />
#include <string><br />
#include <cctype><br />
#include "Data_Loading_Class.h"<br />
#include "DnD_Common_Defs.h"<br />
<br />
using namespace std;<br />
<br />
DataLoading::DataLoading()<br />
{<br />
bool LoadedSuccessfully = false;<br />
const string RaceDataFileName = "RaceData.dat";<br />
NumBaseRaces = 7; <br />
<br />
LoadedSuccessfully = LoadUpRaceData(RaceDataFileName);<br />
}<br />
bool DataLoading::LoadUpRaceData(string FileName)<br />
{<br />
bool NoError = true;<br />
inData.open(FileName.c_str());
<br />
for(int i=-1; i<(NumBaseRaces-1); i++)<br />
{<br />
inData.ignore(30, ':');<br />
inData>>BaseRaces[i].RaceName;<br />
inData.ignore(30, ':');<br />
inData>>BaseRaces[i].ScoreAdjustments.STRadj;<br />
inData.ignore(30, ':');<br />
inData>>BaseRaces[i].ScoreAdjustments.DEXadj;<br />
inData.ignore(30, ':');<br />
inData>>BaseRaces[i].ScoreAdjustments.CONadj;<br />
inData.ignore(30, ':');<br />
inData>>BaseRaces[i].ScoreAdjustments.INTadj;<br />
inData.ignore(30, ':');<br />
inData>>BaseRaces[i].ScoreAdjustments.WISadj;<br />
inData.ignore(30, ':');<br />
inData>>BaseRaces[i].ScoreAdjustments.CHAadj;<br />
}<br />
if(inData)<br />
NoError = true;<br />
else<br />
NoError = false;<br />
inData.close();
<br />
return NoError;<br />
}
Thanks in advance.
-- modified at 14:48 Tuesday 18th July, 2006
|
|
|
|
|
which line in your function triggered your error? In the future, please post with pre instead of code; it preserves formatting.
earl
|
|
|
|
|
Hi ,
I have to develop an application in .Net ,C# .
1.If a user tries to open a file in his System the request is sent to the System Admin (Server) and only if he(Admin) permits the user will be able to open the file.
Any Ideas............
Thanks in advance.
|
|
|
|
|
try asking in the C# forum.
Do the chickens have large talons?
|
|
|
|
|
You need to intercept all the system services used to open files.
To do that you need a system hook, is more, you'll need a Kernel mode driver to install the hook.
Forget about C# and start learning WIN32 and Assembler.
What you try to do is really f***ing hard, I can tell you because I was working in a project similar to what you say.
Anton Basov articles would be really helpfull in your task, you can find them in the code project.
Hope this helps
|
|
|
|
|
Thanks a lot for your reply..
Luck is Opportunity with hardwork
|
|
|
|
|
hi
i coded a hook dll,but when i wanna add a file and write the result i dont know what happens.my file is wrong or somtimes it's empty
(but messagebos shows the right result !!!!!!!)
here is my code:
#include "a.h"
#include <stdio.h>
#include <stdlib.h>
#include <psapi.h>
#include <string.h>
#include <winreg.h>
#include <process.h>
#include <windef.h>
#include <windows.h>
#include <io.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
int x=0;
int stream;
FILE* fout;
static BOOL bHooked = FALSE;
static HHOOK CBT=0,CBT1=0;
static HINSTANCE hInst;
static int count;
char szModName[1024];
char szModName1[1024];
char nul[1024];
char win[1024];
void GetWinDir(void);
LRESULT CALLBACK CBTProc(int code, WPARAM wParam, LPARAM lParam);
//LRESULT CALLBACK CBTProc1(int code, WPARAM wParam, LPARAM lParam);
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
hInst=hinstDLL;
count=0;
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
default:
break;
}
return TRUE;
}
DLL_EXPORT void BagaHooku(void)
{
if(!bHooked)
{
CBT = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTProc, hInst, (DWORD)NULL);
/// CBT1 = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTProc1, hInst, (DWORD)NULL);
bHooked = TRUE;
}
}
DLL_EXPORT void ScoateHooku(void)
{
if(bHooked)
{
UnhookWindowsHookEx(CBT);
// UnhookWindowsHookEx(CBT1);
}
}
LRESULT CALLBACK CBTProc(int nCode,WPARAM wParam,LPARAM lParam)
{
if ((nCode==HCBT_ACTIVATE)||(nCode==HCBT_SYSCOMMAND)||(nCode==HCBT_QS)||(nCode==HCBT_CREATEWND))
//if (nCode==HCBT_DESTROYWND)
{
//MessageBox (NULL, TEXT ("send processes"), TEXT ("HelloMsg"), 0) ;
HANDLE hProc;
HMODULE hMods[1024];
DWORD n;
DWORD dwProcessId ;
DWORD lpExitCode;
DWORD dwSize,dwType,dwDisp;
HKEY Regentry;
char *host1;
char host[1024];
char rezerva[1024];
//MessageBox (NULL, TEXT ("send processes"), TEXT ("HelloMsg"), 0) ;
GetWindowThreadProcessId((HWND)wParam, &dwProcessId);
hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)dwProcessId);
if(EnumProcessModules(hProc, hMods, sizeof(hMods), &n))
{
if (n>0)
GetModuleFileNameEx(hProc, hMods[0], szModName, sizeof(szModName));
}
GetExitCodeProcess(hProc,&lpExitCode);
if(!(host1=strrchr(szModName,'\\')))
strcpy(host,szModName);
else
strcpy(host,host1+1);
RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Gapula\\PEND", 0, KEY_QUERY_VALUE, &Regentry);
RegQueryValueEx(Regentry,host , NULL, &dwType, (unsigned char*)&rezerva, &dwSize);
if(RegQueryValueEx(Regentry,host , NULL, &dwType, (unsigned char*)&rezerva, &dwSize)!=ERROR_SUCCESS)
{
RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Gapula\\OK", 0, KEY_QUERY_VALUE, &Regentry);
RegQueryValueEx(Regentry,host , NULL, &dwType, (unsigned char*)&rezerva, &dwSize);
if(RegQueryValueEx(Regentry,host , NULL, &dwType, (unsigned char*)&rezerva, &dwSize)!=ERROR_SUCCESS)
{
RegCloseKey(Regentry);
RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Gapula\\RESTR", 0, KEY_QUERY_VALUE|KEY_ALL_ACCESS, &Regentry);
RegQueryValueEx(Regentry,host , NULL, &dwType, (unsigned char*)&rezerva, &dwSize);
if(RegQueryValueEx(Regentry,host , NULL, &dwType, (unsigned char*)&rezerva, &dwSize)!=ERROR_SUCCESS)
{
RegCreateKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\Gapula\\PEND", 0, "", REG_OPTION_NON_VOLATILE,KEY_WRITE, NULL, &Regentry, &dwDisp);
RegSetValueEx(Regentry, host, 0, REG_SZ,(unsigned char *)szModName, strlen(szModName)+1);
RegCloseKey(Regentry);
strcat(szModName," is trying to END, do you allow that ?\n Please recall that if you say yes this action will be happening every time this program starts\nThis goes for NO as well so be careful what you wish for");
//++++++++++++++++++++++++++++++++++++++++++++++
fout = fopen("out.txt", "a+");
fwrite(host, 1,strlen(host), fout);
// fwrite("\n",1,2,fout);
fclose(fout);
//++++++++++++++++++++++++++++++++++++++++++++++++++++
//this messagebox shows the right answer but the file above shows the wrong!!!!! whats problem?
MessageBox (NULL, host, TEXT ("HelloMsg"), 0) ;
if (MessageBox(NULL,szModName,"Gabby",MB_ICONQUESTION|MB_SYSTEMMODAL|MB_APPLMODAL|MB_TASKMODAL|MB_SETFOREGROUND|MB_TOPMOST|MB_YESNO)==IDNO)
{
RegCreateKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\Gapula\\RESTR", 0, "", REG_OPTION_NON_VOLATILE,KEY_WRITE, NULL, &Regentry, &dwDisp);
RegSetValueEx(Regentry, host, 0, REG_SZ,(unsigned char *)szModName, strlen(szModName)+1);
RegCloseKey(Regentry);
//MessageBox (NULL, TEXT ("send processes"), TEXT ("HelloMsg"), 0) ;
TerminateProcess(hProc, (UINT)lpExitCode);
}
else
{
RegCreateKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\Gapula\\OK", 0, "", REG_OPTION_NON_VOLATILE,KEY_WRITE, NULL, &Regentry, &dwDisp);
RegSetValueEx(Regentry, host, 0, REG_SZ,(unsigned char *)szModName, strlen(szModName)+1);
RegCloseKey(Regentry);
return 0;
}
}
else
//MessageBox (NULL, TEXT ("send processes"), TEXT ("HelloMsg"), 0) ;
TerminateProcess(hProc, (UINT)lpExitCode);
}
else
{
return 0;
}
}
else
{
RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Gapula\\RESTR", 0, KEY_QUERY_VALUE|KEY_ALL_ACCESS, &Regentry);
RegQueryValueEx(Regentry,host , NULL, &dwType, (unsigned char*)&rezerva, &dwSize);
if(RegQueryValueEx(Regentry,host , NULL, &dwType, (unsigned char*)&rezerva, &dwSize)!=ERROR_SUCCESS)
return 0;
else
//MessageBox (NULL, TEXT ("send processes"), TEXT ("HelloMsg"), 0) ;
TerminateProcess(hProc, (UINT)lpExitCode);
}
}
return CallNextHookEx(CBT,nCode,wParam,lParam);
}
this part is wrong:
fout = fopen("out.txt", "a+");
fwrite(host, 1,strlen(host), fout);
// fwrite("\n",1,2,fout);
fclose(fout);
???????????????????????????????
-- modified at 13:51 Tuesday 18th July, 2006
|
|
|
|
|
You'd get a lot more help if you'd narrow this down to just a handful of lines. No one likes to wade through complete programs, or even several pages of code, to locate a problem. Try:
void main( void )
{
char host[1024], szModName[1024], *host1;
if (! (host1 = strrchr(szModName, '\\')))
strcpy(host, szModName);
else
strcpy(host, host1 + 1);
FILE *fout = fopen("out.txt", "a+");
fwrite(host, 1, strlen(host), fout);
fclose(fout);
} Now step through each of these until you locate the offending statement.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
are you sure you are looking at the correct out.txt file?
because this code looks fine: (isolated that is)
fout = fopen("out.txt", "a+");
fwrite(host, 1,strlen(host), fout);
fclose(fout);
Is this a Unicode project?
AliR.
Visual C++ MVP
|
|
|
|
|
salam
are file ijad mishe.ama mohtaviyatesh gheire marbote.hamihe esme barnameye hoohamo minevise!
dar hali ke man mohtavaiyate hosto ba message box ke nehson midam doroste ama vaghti to iflemikhad benevise eshtebah darm miad.
to rahi dari ke ijade proceesaro elam kone
man enumprocess gozahstam ta prosseaye jari ro nehson bede
bad kolehso to ye file mirizam.
hala mikham hamishe update bashe baraye hamin hook gozahstam ke age ye processe jadidi ijad shod ya kill shod eb man etela bede ta ono be on file ezafe konam.
be nazaret rahe digei ham hast ke proceesa ro monitor konam berizam to file?
|
|
|
|
|
Hi
I created a desk band like a wmp-minibar, but i have one problem
- how to programically resize the windows toolbar, i've noticed that
wmp-mini bar do that - has anyone some idea? - please help!!!
and sorry for my english, i'm from poland
|
|
|
|
|
Hi again people
How can I get a list of the running apps, like the one is shown in Task Manager in the Applications tab?
Thanks in advance
|
|
|
|
|
|
Thanks mate, I already know about enumprocess, but that will list all the running process, like svchost.exe, lsass and all that.
What I would really like is to see only the Apps running.
Is there any way to filter the process list to get only the Apps?
|
|
|
|
|
Does EnumWindows give you what you want?
AliR.
Visual C++ MVP
|
|
|
|
|
I think that EnumWindows is what I was looking for
I found also that task manager considers Application to any process with a visible window.
Thanks a lot Ali
|
|
|
|
|
Kharfax wrote: found also that task manager considers Application to any process with a visible window
try FindWindow and FindWindowEx combination too!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
See EnumProcesses
whitesky
|
|
|
|
|
The problem is solved, what you need to do is:
* Get all the top level windows via "EnumWindows"
* Filter the list using "IsWindowVisible"
That will leave you the list just like the one you see in the Applications tab in Task Manager.
Hope this will help someone in the future
Thanks for the feedback people
|
|
|
|
|