Click here to Skip to main content
15,886,110 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: auto finding the dir the exe is in Pin
Hamid_RT1-Jun-06 19:31
Hamid_RT1-Jun-06 19:31 
AnswerRe: auto finding the dir the exe is in Pin
toxcct1-Jun-06 21:42
toxcct1-Jun-06 21:42 
QuestionIs DCB setttings important if using virtual COM port? Pin
tctan1-Jun-06 17:31
tctan1-Jun-06 17:31 
AnswerRe: Is DCB setttings important if using virtual COM port? Pin
ThatsAlok1-Jun-06 20:29
ThatsAlok1-Jun-06 20:29 
GeneralRe: Is DCB setttings important if using virtual COM port? [modified] Pin
tctan1-Jun-06 22:02
tctan1-Jun-06 22:02 
AnswerRe: Is DCB setttings important if using virtual COM port? [modified] Pin
Roger Stoltz1-Jun-06 22:51
Roger Stoltz1-Jun-06 22:51 
Questionabout smtp server problem ,thanks Pin
alicqin1-Jun-06 16:34
alicqin1-Jun-06 16:34 
QuestionPointer/structure usage Pin
fourierman1-Jun-06 16:28
fourierman1-Jun-06 16:28 
I should know pointers by now but still struggle to get code working when dealing with them..

If anyone has any recommended articles I'd be very appreciative. But, the articles dealing with pointer basics don't seem to help me... not sure why. I can understand casting ints, etc. but when it gets to more complex data types, I get confused.

A good example of a tough pointer problem for me is seen below. Not sure why/where I'm reading/changing memory I shouldn't be and I also don't know how I would be able to get the value of the TextualSid in a format usable for strcmp, printf, etc.

Thanks..
//////////
<br />
LPUSER_INFO_23 pBuf = NULL;<br />
LPTSTR TextualSid ;<br />
LPTSTR * TextualSid2= NULL ;<br />
<br />
ConvertSidToStringSid(pBuf, TextualSid2); <br />
//printf("User SID = %s\n",(char*)TextualSid2);<br />
			<br />
// alternate method<br />
<br />
DWORD sidLen;<br />
sidLen = GetLengthSid(pBuf);<br />
LPDWORD lpdwSize = NULL;<br />
*lpdwSize = sidLen;<br />
GetTextualSid(pBuf->usri23_user_sid, TextualSid, (LPDWORD)lpdwSize);<br />
if (pBuf != NULL) NetApiBufferFree(pBuf);<br />
			<br />
Data types used: <br />
/*	typedef struct _USER_INFO_23 {  <br />
		LPWSTR usri23_name;  <br />
		LPWSTR usri23_full_name;  <br />
		LPWSTR usri23_comment;  <br />
		DWORD usri23_flags;  <br />
		PSID usri23_user_sid; // usri23_user_sid : Pointer to a SID structure that contains the security identifier (SID) that uniquely identifies the user<br />
	} USER_INFO_23,  <br />
	  *PUSER_INFO_23,  <br />
	  *LPUSER_INFO_23;<br />
<br />
	  <br />
NET_API_STATUS NetUserGetInfo(<br />
  LPCWSTR servername,<br />
  LPCWSTR username,<br />
  DWORD level,<br />
  LPBYTE* bufptr<br />
);<br />
*/<br />
<br />
BOOL GetTextualSid( // from MSDN<br />
    PSID pSid,            // binary SID<br />
    LPTSTR TextualSid,    // buffer for Textual representation of SID<br />
    LPDWORD lpdwBufferLen // required/provided TextualSid buffersize<br />
    )<br />
{<br />
    PSID_IDENTIFIER_AUTHORITY psia;<br />
    DWORD dwSubAuthorities;<br />
    DWORD dwSidRev=SID_REVISION;<br />
    DWORD dwCounter;<br />
    DWORD dwSidSize;<br />
<br />
    // Validate the binary SID.<br />
<br />
    if(!IsValidSid(pSid)) return FALSE;<br />
<br />
    // Get the identifier authority value from the SID.<br />
<br />
    psia = GetSidIdentifierAuthority(pSid);<br />
<br />
    // Get the number of subauthorities in the SID.<br />
<br />
    dwSubAuthorities = *GetSidSubAuthorityCount(pSid);<br />
<br />
    // Compute the buffer length.<br />
    // S-SID_REVISION- + IdentifierAuthority- + subauthorities- + NULL<br />
<br />
    dwSidSize=(15 + 12 + (12 * dwSubAuthorities) + 1) * sizeof(TCHAR);<br />
<br />
    // Check input buffer length.<br />
    // If too small, indicate the proper size and set the last error.<br />
<br />
    if (*lpdwBufferLen < dwSidSize)<br />
    {<br />
        *lpdwBufferLen = dwSidSize;<br />
        SetLastError(ERROR_INSUFFICIENT_BUFFER);<br />
        return FALSE;<br />
    }<br />
<br />
    // Add 'S' prefix and revision number to the string.<br />
<br />
    dwSidSize=wsprintf(TextualSid, TEXT("S-%lu-"), dwSidRev );<br />
<br />
    // Add a SID identifier authority to the string.<br />
<br />
    if ( (psia->Value[0] != 0) || (psia->Value[1] != 0) )<br />
    {<br />
        dwSidSize+=wsprintf(TextualSid + lstrlen(TextualSid),<br />
                    TEXT("0x%02hx%02hx%02hx%02hx%02hx%02hx"),<br />
                    (USHORT)psia->Value[0],<br />
                    (USHORT)psia->Value[1],<br />
                    (USHORT)psia->Value[2],<br />
                    (USHORT)psia->Value[3],<br />
                    (USHORT)psia->Value[4],<br />
                    (USHORT)psia->Value[5]);<br />
    }<br />
    else<br />
    {<br />
        dwSidSize+=wsprintf(TextualSid + lstrlen(TextualSid),<br />
                    TEXT("%lu"),<br />
                    (ULONG)(psia->Value[5]      )   +<br />
                    (ULONG)(psia->Value[4] <<  8)   +<br />
                    (ULONG)(psia->Value[3] << 16)   +<br />
                    (ULONG)(psia->Value[2] << 24)   );<br />
    }<br />
<br />
    // Add SID subauthorities to the string.<br />
    //<br />
    for (dwCounter=0 ; dwCounter < dwSubAuthorities ; dwCounter++)<br />
    {<br />
        dwSidSize+=wsprintf(TextualSid + dwSidSize, TEXT("-%lu"),<br />
                    *GetSidSubAuthority(pSid, dwCounter) );<br />
    }<br />
<br />
    return TRUE;<br />
}<br />

QuestionCDialog DoModal doesn't work inside threads? Pin
Dennis Furlaneto1-Jun-06 16:01
Dennis Furlaneto1-Jun-06 16:01 
AnswerRe: CDialog DoModal doesn't work inside threads? Pin
Nibu babu thomas1-Jun-06 17:40
Nibu babu thomas1-Jun-06 17:40 
GeneralRe: CDialog DoModal doesn't work inside threads? Pin
Dennis Furlaneto2-Jun-06 3:35
Dennis Furlaneto2-Jun-06 3:35 
QuestionCan anyone see the problem-newbie [modified] Pin
antonaras1-Jun-06 8:34
antonaras1-Jun-06 8:34 
AnswerRe: Can anyone see the problem-newbie Pin
antonaras1-Jun-06 8:36
antonaras1-Jun-06 8:36 
AnswerRe: Can anyone see the problem-newbie Pin
Chris Losinger1-Jun-06 8:46
professionalChris Losinger1-Jun-06 8:46 
AnswerRe: Can anyone see the problem-newbie [modified] Pin
Zac Howland1-Jun-06 8:59
Zac Howland1-Jun-06 8:59 
AnswerRe: Can anyone see the problem-newbie [modified] Pin
David Crow1-Jun-06 9:19
David Crow1-Jun-06 9:19 
QuestionAnyone know of a good commercial debugger? Pin
leon91-Jun-06 7:01
leon91-Jun-06 7:01 
AnswerRe: Anyone know of a good commercial debugger? Pin
toxcct1-Jun-06 7:25
toxcct1-Jun-06 7:25 
GeneralRe: Anyone know of a good commercial debugger? Pin
BadKarma1-Jun-06 7:47
BadKarma1-Jun-06 7:47 
AnswerRe: Anyone know of a good commercial debugger? Pin
Blake Miller1-Jun-06 8:13
Blake Miller1-Jun-06 8:13 
AnswerRe: Anyone know of a good commercial debugger? Pin
leon91-Jun-06 8:49
leon91-Jun-06 8:49 
AnswerRe: Anyone know of a good commercial debugger? Pin
Zac Howland1-Jun-06 8:51
Zac Howland1-Jun-06 8:51 
AnswerRe: Anyone know of a good commercial debugger? Pin
Kevin McFarlane1-Jun-06 11:40
Kevin McFarlane1-Jun-06 11:40 
GeneralRe: Anyone know of a good commercial debugger? Pin
lastgen1-Jun-06 19:14
lastgen1-Jun-06 19:14 
GeneralRe: Anyone know of a good commercial debugger? Pin
Kevin McFarlane2-Jun-06 0:21
Kevin McFarlane2-Jun-06 0:21 

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.