Click here to Skip to main content
16,006,605 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalsubclassed mfc control Pin
Tym!20-Jan-03 9:41
Tym!20-Jan-03 9:41 
GeneralRe: subclassed mfc control Pin
Navin20-Jan-03 10:44
Navin20-Jan-03 10:44 
GeneralYet another dll question Pin
VanHlebar20-Jan-03 9:01
VanHlebar20-Jan-03 9:01 
GeneralStart Menu Shortcut Pin
Ken Mazaika20-Jan-03 8:52
Ken Mazaika20-Jan-03 8:52 
GeneralRe: Start Menu Shortcut Pin
Todd Smith20-Jan-03 8:59
Todd Smith20-Jan-03 8:59 
GeneralRe: Start Menu Shortcut Pin
Ken Mazaika20-Jan-03 9:04
Ken Mazaika20-Jan-03 9:04 
Generaldisable the maxmize in SDI Pin
zoka20-Jan-03 8:45
zoka20-Jan-03 8:45 
GeneralDisplay User Name in the Event Viewer Pin
Anonymous20-Jan-03 8:41
Anonymous20-Jan-03 8:41 
this piece of code works fine without the msdn code. He generate an event for "Event Error" registry entry.

[code]

void CEventTestDlg::OnOK()
{
HANDLE hEvent;
CString strInfo;
char *szList[1];

strInfo = "Hellow World";
szList[0] = strInfo.GetBuffer(0);

hEvent = RegisterEventSource(NULL, "Event Error");

ReportEvent(hEvent, EVENTLOG_INFORMATION_TYPE, 2, NULL, NULL, 1, 0, (const char**)szList, NULL);

strInfo.ReleaseBuffer();

DeregisterEventSource(hEvent);

}

[/code]

Now, I went to MSDN to get another piece of code. I believe this code suppose to display the user in the event viewer under the user field. But for any reason, I can't get it to work with my. Here is the whole code. I keep getting some errors. Can somebody fix that for me.


[code]
void CEventTestDlg::OnOK()
{
HANDLE hEvent;
CString strInfo;
char *szList[1];
LPSTR pszUser;
LPDWORD pcbUser;
EVENTLOGRECORD *perl;

strInfo = "Hellow World";
szList[0] = strInfo.GetBuffer(0);

hEvent = RegisterEventSource(NULL, "ErrLogServer");

ReportEvent(hEvent, EVENTLOG_INFORMATION_TYPE, 2, NULL, NULL, 1, 0, (const char**)szList, NULL);

strInfo.ReleaseBuffer();

GetEventUserName(EVENTLOGRECORD *pelr, LPSTR pszUser, LPDWORD pcbUser);

DeregisterEventSource(hEvent);

}

BOOL GetEventUserName(EVENTLOGRECORD *pelr, LPSTR pszUser, LPDWORD pcbUser)
{
PSID lpSid;
char szName[256];
char szDomain[256];
SID_NAME_USE snu;
DWORD dwLen;
DWORD cbName = 256;
DWORD cbDomain = 256;

// Point to the SID.
lpSid = (PSID)((LPBYTE) pelr + pelr->UserSidOffset);

if (LookupAccountSid(NULL, lpSid, szName, &cbName, szDomain,
&cbDomain, &snu))
{
// Determine whether the buffer is large enough.
dwLen = lstrlen(lpszUser) + 1;

if (dwLen > *lpcbUser)
{
SetLastError( ERROR_INSUFFICIENT_BUFFER );
*lpcbUser = dwLen;
return FALSE;
}

// Return the user's name.
lstrcpy( lpszUser, szName );

}
else
{
// Use the error status from LookupAccountSid.
return FALSE;
}

SetLastError(0);
return TRUE;
}

[/code]

All that I want, I want to display the username under the user field. I don't know if this function is supposed to do that or retrieve the username. I have tried another approach by using a message compiller. If somebody knows a method I can use or send me or posted a simple code, that will be fine.

QuestionWhat is the Last Message Posted... Pin
Nitron20-Jan-03 8:30
Nitron20-Jan-03 8:30 
AnswerRe: What is the Last Message Posted... Pin
Michael Dunn20-Jan-03 8:40
sitebuilderMichael Dunn20-Jan-03 8:40 
GeneralRe: What is the Last Message Posted... Pin
Nitron20-Jan-03 8:44
Nitron20-Jan-03 8:44 
QuestionSomething wrong with Petzold's code? Pin
georgiek5020-Jan-03 7:59
georgiek5020-Jan-03 7:59 
AnswerRe: Something wrong with Petzold's code? Pin
Tim Smith20-Jan-03 8:11
Tim Smith20-Jan-03 8:11 
AnswerRe: Something wrong with Petzold's code? Pin
Michael Dunn20-Jan-03 8:19
sitebuilderMichael Dunn20-Jan-03 8:19 
GeneralRe: Something wrong with Petzold's code? Pin
georgiek5020-Jan-03 13:38
georgiek5020-Jan-03 13:38 
GeneralRe: Something wrong with Petzold's code? Pin
Tim Smith20-Jan-03 14:00
Tim Smith20-Jan-03 14:00 
QuestionFree library that handles sending e-mail? Pin
fferland20-Jan-03 7:40
fferland20-Jan-03 7:40 
AnswerRe: Free library that handles sending e-mail? Pin
Jon Sagara20-Jan-03 7:49
Jon Sagara20-Jan-03 7:49 
GeneralRe: Free library that handles sending e-mail? Pin
Jon Sagara20-Jan-03 10:46
Jon Sagara20-Jan-03 10:46 
GeneralPrint & Print Preview Pin
nelzanoide20-Jan-03 7:24
nelzanoide20-Jan-03 7:24 
GeneralOnPaint ( ) and initialization Pin
john john mackey20-Jan-03 6:57
john john mackey20-Jan-03 6:57 
QuestionWho can plz help me to find the sample code? Pin
withoutdruck20-Jan-03 6:25
withoutdruck20-Jan-03 6:25 
AnswerRe: Who can plz help me to find the sample code? Pin
Joaquín M López Muñoz20-Jan-03 7:37
Joaquín M López Muñoz20-Jan-03 7:37 
GeneralMouseover tabs Pin
Vamp20-Jan-03 5:50
Vamp20-Jan-03 5:50 
QuestionHow to use LoadMenuIndirect function ? Pin
dktu20-Jan-03 5:33
dktu20-Jan-03 5:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.