|
1 - RegisterDeviceNotification
2 - you can register a notification callback on changes to registry keys
earl
|
|
|
|
|
Thank you for pointing me in the right direction. I will try that tonight.
|
|
|
|
|
Hi fellows
In my app I have a treeview with some nodes. I want to select one of them and it will be highlighted. The problem is that I don`t get highlighted neither selected. This is my code to select a node:
[Code]
case WM_NOTIFY:
{
LPNMHDR notifyMessageStruct = (LPNMHDR)lParam;
if(notifyMessageStruct->hwndFrom == treeViewHwnd)
{
if(notifyMessageStruct->code == NM_CLICK)
{
nodeSelected = (HTREEITEM)SendDlgItemMessage(hwnd, IDC_TREE1, TVM_GETNEXTITEM, TVGN_CARET, (LPARAM)nodeSelected);
if(nodeSelected == NULL)MessageBox(NULL, "", "", MB_OK);
TreeView_EnsureVisible(hwnd, nodeSelected);
SendDlgItemMessage(hwnd, IDC_TREE1, TVM_SELECTITEM, TVGN_CARET, (LPARAM)nodeSelected);
SendDlgItemMessage(hwnd, IDC_TREE1, TVM_SELECTITEM, TVGN_DROPHILITE, 0);
}
}
break;
}
[/Code]
My code to create the treeview:
[Code]
treeViewHwnd = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "theTreeView", WS_CHILD|WS_VISIBLE|TVS_TRACKSELECT|TVS_EDITLABELS|TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT, 0, 0, 400, myRect.bottom, hwnd, (HMENU)IDC_TREE1, hCurrentInstance, NULL);
[/Code]
Someone can helps? Thanks again
|
|
|
|
|
Not really sure what you are trying to do there. But maybe the tree doesn't have the focus and that's why you are not seeing the selection.
Add this TVS_SHOWSELALWAYS to the flags when you are creating the tree to see if that helps.
AliR.
Visual C++ MVP
|
|
|
|
|
I've been apointed to provide support for an old project which exports some data in xml files and then posts them on some web server. The problem is that the person that worked with this project before me does not check the xml data for chars like '<','>','&' and so forth.
The ideea is that instead of goint trough all the project and finding out where those xml's are created, i want to check them right before they get posted (which thankfuly is done by a single method).
Is there another way of finding '<' and '>' chars that are part of a node data without searching that file char by char?
|
|
|
|
|
|
I am attempting to play a sound when a button is clicked. I am using Microsoft Visual Studio .NET 2003 and to create my project I clicked File->New->Project, chose Visual C++ Projects and then Windows Forms Application (.NET). I then added a button to the form and in the click event I put the following code
PlaySound(_T("C:\\Windows\\Media\\chime.wav"), NULL, SND_LOOP);
I also included at the top of the file windows.h.
The errors that I receive are
error C2065: 'SND_LOOP' : undeclared identifier
error C3861: 'PlaySound': identifier not found, even with argument-dependent lookup
I would appreciate any help.
Thanks in advance
Keith
|
|
|
|
|
You created a managed application and PlaySound is an unmanaged function.
See this for help
CodeProject search[^]
AliR.
Visual C++ MVP
|
|
|
|
|
Did you include Mmsystem.h
whitesky
|
|
|
|
|
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?
|
|
|
|
|