|
Hi all,
I'm using the following function to read the Source of the System events. I'm trying to check if the source name is equal to "Windows Agent" or if the EventId is equal to 21. Which would indicate that the computer needs a restart. But I don't get any result and there is without a doubt such an entry in the event log.
oid DisplayEntries( )
{
HANDLE h;
EVENTLOGRECORD *pevlr;
BYTE bBuffer[BUFFER_SIZE];
DWORD dwRead, dwNeeded, cRecords, dwThisRecord;
int counter=0;
h = OpenEventLog( NULL,
"System");
if (h == NULL)
{
Form1->msg = Form1->msg.sprintf("Could not open the Application event log.");
Form1->Memo2->Lines->Add(Form1->msg);
}
pevlr = (EVENTLOGRECORD *) &bBuffer;
GetOldestEventLogRecord(h, &dwThisRecord);
while (ReadEventLog(h,
EVENTLOG_FORWARDS_READ |
EVENTLOG_SEQUENTIAL_READ,
0,
pevlr,
BUFFER_SIZE,
&dwRead,
&dwNeeded))
{
while (dwRead > 0)
{
printf("%02d Event ID: 0x%08X ",
dwThisRecord++, pevlr->EventID);
printf("EventType: %d Source: %s\n",
pevlr->EventType, (LPSTR) ((LPBYTE) pevlr +
sizeof(EVENTLOGRECORD)));
if ((LPSTR)((LPBYTE) pevlr + sizeof(EVENTLOGRECORD))=="Windows Agent")
{
MessageBox(NULL, "FOUND", "INFO",MB_OK);
}
dwRead -= pevlr->Length;
pevlr = (EVENTLOGRECORD *)
((LPBYTE) pevlr + pevlr->Length);
}
pevlr = (EVENTLOGRECORD *) &bBuffer;
}
CloseEventLog(h);
}
Many Thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
The first error lies in the following line
if ((LPSTR)((LPBYTE) pevlr + sizeof(EVENTLOGRECORD))=="Windows Agent")
What you are performing is a pointer comparison with a static string. This is only going to work in two ways
if the expression (LPSTR)((LPBYTE) pevlr + sizeof(EVENTLOGRECORD)) is used to initialise a string class like std::string or CString etc
a more straight forward way is to use a string compariosn function eg strcmp or its wide equivalent if you have a Unicode project.
i.e.
if(strcmnp((LPSTR)((LPBYTE) pevlr + sizeof(EVENTLOGRECORD)),"Windows Agent") == 0)
The other problem you might face is user priveledge as access to a system resource like the event logs may be restricted if you are not an Admin user.
|
|
|
|
|
I have a program(.exe).I want to know which actions it did when it running.
How can I explore such tasks?
Thank you.
GOOD LUCK.
|
|
|
|
|
What do you want to do exactly ? Define what you mean by 'action'.
|
|
|
|
|
Really,I have a iPod MP4 player.
I want to program a small tool to update new mp4/mp3 file.
The MP4 player has a additional tool,it can do it well.The tool change the file(which you want to update) name as a four characters long new name and map the file path and original name in a database file.
I want to do it by myself and imitate such task.
But I do not know the format of the database file and also do not know how to make a map in the database.
Would you like to give me a guide?Thanks.
GOOD LUCK
|
|
|
|
|
Can you more explain about your program and what do you want which actions?
|
|
|
|
|
Really,I have a iPod MP4 player.
I want to program a small tool to update new mp4/mp3 file.
The MP4 player has a additional tool,it can do it well.The tool change the file(which you want to update) name as a four characters long new name and map the file path and original name in a database file.
I want to do it by myself and imitate such task.
But I do not know the format of the database file and also do not know how to make a map in the database.
Would you like to give me a guide?Thanks.
GOOD LUCK
|
|
|
|
|
Add debug output using OutputDebugString to record what has happened.
User the Windows tool ProcessExplorer to examine File handles events etc that the exe is performing.
|
|
|
|
|
Hello to all,
right now i am trying to upload a file on the server in VC++(MFC), currently i can upload a file directly on the server but i want to upload a file in a perticular folder on the server that i am unable to do, bcoz whenever i add that folder name to the our server address in the code then after execution i get a message "server name or address can not be resolved" and so connetion with server can not be done. I am using CInternetSession and CFtpConnection classes and GetFtpConnection(),PutFile() and GetFile() functions of these classes for uploading and downloading. can anybody help me?
Anay Kulkarni
|
|
|
|
|
I believe you should add it to the 'pstrRemoteFile' parameter of the PutFile() / GetFile() calls instead of to the server address. Instead of asking for
myfile.txt
ask for
subdir1/subdir2/myfile.txt
See if that works for you.
|
|
|
|
|
yes, it worked fine. thanks a lot sir.
Anay
|
|
|
|
|
Are you calling the connection's SetCurrentDirectory() method before PutFile() ?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I use VC2005.I found a new error I have never met before.
error C2220: warning treated as error - no 'object' file generated
How should I fixed it ?
Thanks.
GOOD LUCK
|
|
|
|
|
Try checking this[^] out.
Steve
|
|
|
|
|
kcynic wrote: How should I fixed it ?
Start by reading this.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
consider
<br />
class Car<br />
{<br />
int speed;<br />
doulbe engineSize;<br />
};<br />
<br />
I persoanlly dislike code like this. I tend to make all data members private and provide inlined get and set methods where appropriate. The main reason I like the get and set methods is its easier to debug code as you can put a break point in the set method for example and catch every change to the value. Also it prevents people taking the address of these variables and manipulating them through pointers which can also be hard to track down in a large project.
Im interested to hear the opinions of others on the use of public data members or getter and setter methods
|
|
|
|
|
I mostly use "get" and "set" methods to access data members which are private by default. However, there are rare special situations where I do access public fields directly.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
In my opinion it depends about what is being done. In my studies final project I was using GET and SET everywhere, but not with numbers or easy variables. I was using them with objects that holded more than hundred parameters (its sizeof (myObject) in some points were in KB). Because of that when I was searching elements of the third hierarchy (it means go in a collection of elements, where every element has a collections of other elements, and then search for the concrete parameter inside another collection), the program was f***ing slow and needed a lot of resources to get the object between classes.
I change it to public and worked with pointers/references and then all was fine.
I like to use Get and Set, but sometimes is impossible.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
A couple thoughts...
Inline getters and setters should work just as fast as direct access.
An advantage of getters and setters is you can change the implementation without
having to change code anywhere else. For example, if in the future you need to calculate
the "speed" member on the fly, all you'd have to do is implement that functionality in the getter
method. All code that uses it stays the same.
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all, quick question. I've read the MSDN library definition for this API and all i really want to know is can i use it to find a running program or not. Still searhing for a example of this API in use so its still very un-clear to me. Thanx in advance!
|
|
|
|
|
EnumProcesses shows each process on the system but what do you need exactly?
|
|
|
|
|
DWORD dwPID[16860];
DWORD dwRet;
DWORD dwNumProcesses;
if (TRUE == EnumProcesses(dwPID,sizeof(dwPID),&dwRet))
{
dwNumProcesses = dwRet / (sizeof(DWORD);
for(int i =0;i < dwNumProcesses;++i)
{
printf(_T("Process ID = %d"),dwPID[i];
}
}
Best Wishes,
-Randor (David Delaune)
|
|
|
|
|
This function can check if a process is running by checking the executable name. You may want to add additional checking such as window class enumeration or enumeration of known loaded modules.
BOOL IsExecutableRunning(TCHAR *lpszExe)
{
HANDLE hSnapShot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
PROCESSENTRY32 processInfo;
processInfo.dwSize=sizeof(PROCESSENTRY32);
while(Process32Next(hSnapShot,&processInfo)!=FALSE)
{
if(processInfo.th32ProcessID > 12 && _tclen(processInfo.szExeFile) > 0)
{
if(_tcscmp(processInfo.szExeFile,lpszExe) == 0)
{
CloseHandle(hSnapShot);
return TRUE;
}
}
}
CloseHandle(hSnapShot);
return FALSE;
}
Best Wishes,
-Randor (David Delaune)
|
|
|
|
|
I am trying to get and set the following information from File/Open save dialog of Microsoft Office 2000/2003/2007
1.Retrieve the currently displayed/selected folder path and also the file name that is selected if any.
2. Retrieve the selected file path, when the user clicks the open or save button.
3.Set a pre-defined string path within the file-name combo box.
I have been able to do the above task in case of File Open/Save common controls dialog(used by WordPad ,Notepad,
Acrobat Reader etc.) by using the dialog functions depicted in MSDN. But it is not working with Microsoft Office Dialog and I have found no MSDN documentation that depicts the internal messages of Microsoft Office Dialogs.
Please help me if you can.
Thanks and regards,
|
|
|
|
|
Microsoft Office doesn't use the common dialog for file open/save AFAIK.
The Office dialogs may well be undocumented. From our point of view, the
MS Office suite of applications are proprietary 3rd-party applications, not part of the
operating system, so there's no reason the dialogs and their functionality should be
documented.
You may get a reply here from someone with the info you need.
In the meantime, here's a couple links you may or may not have been to already:
Office Developer Center[^]
MSDN Newsgroups: Office Solutions Development[^]
That's all the info I have
Good luck!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|