Click here to Skip to main content
15,912,329 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Outprocess Control Pin
Tracy Software29-Dec-11 0:35
Tracy Software29-Dec-11 0:35 
AnswerRe: Outprocess Control Pin
Tracy Software29-Dec-11 0:55
Tracy Software29-Dec-11 0:55 
QuestionTAPI Call program Pin
Hadi Dayvary28-Dec-11 22:05
professionalHadi Dayvary28-Dec-11 22:05 
QuestionHow to retrieve another cookies from InternetGetCookie() when the website sets multiple cookies. Pin
Avinash Pachar27-Dec-11 21:22
Avinash Pachar27-Dec-11 21:22 
QuestionRe: How to retrieve another cookies from InternetGetCookie() when the website sets multiple cookies. Pin
David Crow28-Dec-11 4:20
David Crow28-Dec-11 4:20 
AnswerRe: How to retrieve another cookies from InternetGetCookie() when the website sets multiple cookies. Pin
Chuck O'Toole28-Dec-11 5:16
Chuck O'Toole28-Dec-11 5:16 
QuestionRe: How to retrieve another cookies from InternetGetCookie() when the website sets multiple cookies. Pin
Avinash Pachar3-Jan-12 21:21
Avinash Pachar3-Jan-12 21:21 
QuestionRe: How to retrieve another cookies from InternetGetCookie() when the website sets multiple cookies. Pin
Avinash Pachar9-Jan-12 22:28
Avinash Pachar9-Jan-12 22:28 
QuestionWriting data on exif Pin
eduardocardoso27-Dec-11 6:09
eduardocardoso27-Dec-11 6:09 
QuestionSystem Query Pin
john563227-Dec-11 0:16
john563227-Dec-11 0:16 
AnswerRe: System Query Pin
Randor 27-Dec-11 11:46
professional Randor 27-Dec-11 11:46 
GeneralRe: System Query Pin
john563227-Dec-11 19:36
john563227-Dec-11 19:36 
SuggestionRe: System Query Pin
David Crow28-Dec-11 4:18
David Crow28-Dec-11 4:18 
GeneralRe: System Query Pin
Randor 28-Dec-11 11:11
professional Randor 28-Dec-11 11:11 
GeneralRe: System Query Pin
john563227-Dec-11 20:27
john563227-Dec-11 20:27 
GeneralRe: System Query Pin
Randor 28-Dec-11 11:08
professional Randor 28-Dec-11 11:08 
GeneralRe: System Query Pin
john563229-Dec-11 18:23
john563229-Dec-11 18:23 
GeneralRe: System Query Pin
Randor 29-Dec-11 18:47
professional Randor 29-Dec-11 18:47 
GeneralRe: System Query Pin
john563229-Dec-11 20:29
john563229-Dec-11 20:29 
GeneralRe: System Query Pin
Randor 29-Dec-11 21:57
professional Randor 29-Dec-11 21:57 
QuestionJoining 2 values with wcsncat_s Pin
jkirkerx26-Dec-11 10:52
professionaljkirkerx26-Dec-11 10:52 
I'm having trouble with cating 2 values together, one of the buffers is not null terminated.

So I made a buffer to a pointer, that I passed to a function.

C#
// Make a copy of the new Server Name
int iNSN = wcslen(pzAddServerName)*sizeof(WCHAR);
szAddServerName = new WCHAR[iNSN+1];
wcsncpy_s(szAddServerName, iNSN, pzAddServerName, wcslen(pzAddServerName) );


I learned that the wcsncpy will automatically null terminate the szAddServerName, which is a copy of the pointer, which is not null terminated.

I then made a copy of the master list, with a new buffer, and assumed that the wcsncpy will null terminate the buffer. I added extra space for the new name and the delimiter plus null terminator.

C#
// Make a copy of the registry values
int iASN = wcslen(pzEnumeratedServerNames)+wcslen(szAddServerName);
szNewServerNames = new WCHAR[iASN+4];
wcsncpy_s(szNewServerNames, iASN, pzEnumeratedServerNames, wcslen(pzEnumeratedServerNames) );


And then if the new name is not in the list of names, tried to cat it to the list of names.

C#
if (pzMatch == NULL) {
// one of these is not null terminated
wcsncat_s(szNewServerNames, wcslen(szNewServerNames), szAddServerName, wcslen(szAddServerName) );
}


I know that I can walk through the code to figure out which one is not null terminated, but I really need to get a rock solid rule in my head, to avoid this in the future, where I just do it right the first time.
AnswerRe: Joining 2 values with wcsncat_s Pin
Chris Losinger26-Dec-11 10:59
professionalChris Losinger26-Dec-11 10:59 
GeneralRe: Joining 2 values with wcsncat_s Pin
jkirkerx26-Dec-11 11:13
professionaljkirkerx26-Dec-11 11:13 
QuestionNetwork Utilization Pin
john563225-Dec-11 22:13
john563225-Dec-11 22:13 
AnswerRe: Network Utilization Pin
Richard MacCutchan26-Dec-11 6:57
mveRichard MacCutchan26-Dec-11 6:57 

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.