|
Well, of course ii=ii+1; cannot give such an exception, you have to check, using the debugger, for out-of-boundary array access, i.e. if ii happen to be 20 or more in code containing sd_dis[ii] or ftitle[ii] .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Thanks for the comments:
I can not find anything like "if ii happen to be 20 or more in code containing sd_dis[ii] or ftitle[ii].". At ii=ii+1 the error pointed in the debudg at the following statement:
->> 00433872 mov dword ptr [ecx],edx
Thanks for the help
|
|
|
|
|
Could please post the whole error message (and the whole code snippet)?
What is the ii value when the exception occurs?
BTW the assembly instruction reported doesn't appear to be an integer increment operation: it seems more an array access.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
We used to use strncpy to protect the buffer when copying into it. Does strcpy_s totally take that over?
I know when I debug, that sometimes I get a runtime error inside strcpy_s when the source string is longer than the buffer.
Will this runtime error appear in a non-debug build?
And should I really be using strncpy_s() instead of strcpy_s()?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
Peter Weyzen wrote: And should I really be using strncpy_s() instead of strcpy_s()?
Only if you need to tell the function how many characters to copy.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I guess it was the exception inside strcpy_s that got me.
I hope that's debug only....
What's your opinion of the _s funtions? They seem long overdue...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
Peter Weyzen wrote: What's your opinion of the _s funtions? They seem long overdue...
Non-portable, slow and also not very secure either.
|
|
|
|
|
Hi all,
I've see apps before where you click a button and it shows you a listbox with local SMTP server(s). How exactly is this done? I've done some research into querying MX records, and also the DnsQuery function in Windows, but they don't help at all.
Can anyone give me some pointers?
Thanks in advance.
|
|
|
|
|
hxhl95 wrote: How exactly is this done?
DnsQuery() is but one way.
PDNS_RECORD pRec = NULL;
DnsQuery(lpszHostDomain, DNS_TYPE_MX, DNS_QUERY_STANDARD, NULL, &pRec, NULL);
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
How would I find the host domain though?
|
|
|
|
|
Can't you use whatever domain you are sending the e-mail to?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I could, but I've seen apps where they get the local domain...I'm just curious. I mean, of course it would work to get the domain of the recipient's email(s), but I'd like to know how you get the local domain name.
And...to use DnsQuery you have to include WinDNS.h and add dnsapi.lib to your library files, right? I've added dnsapi.lib in, but my VC++ 6.0 compiler tells me that it can't find the file. Why? (I've installed the SDK already)
modified on Saturday, January 26, 2008 11:21:58 PM
|
|
|
|
|
hxhl95 wrote: ...but my VC++ 6.0 compiler tells me that it can't find the file. Why?
Is your SDK's Include folder known by the IDE (it's not by default)? If you use an absolute path with dnsapi.lib, does that satisfy the linker?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yeah, the IDE knows the include folder's path. I added it in.
Apparently though, everything works without Dnsapi.lib. MSDN told me that DnsQuery needed dnsapi.lib, but I guess not.
So one question remains: Is there any way to obtain the local domain?
|
|
|
|
|
hxhl95 wrote: ...but I guess not.
So what other library do you suppose its hiding in?
hxhl95 wrote: So one question remains: Is there any way to obtain the local domain?
hxhl95 wrote: So one question remains: Is there any way to obtain the local domain?
You can use NetWkstaGetInfo() for this.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
About NetWkstaGetInfo():
LPWKSTA_INFO_100 netinfo = NULL;<br />
if (NetWkstaGetInfo(NULL,100,(LPBYTE*)netinfo)!=NERR_Success){<br />
MessageBox("Error");<br />
return;<br />
}
I get the messagebox each time. Any clues as to why the function isn't getting the info properly? I debugged, and past the NetWkstaGetInfo line, netinfo points to 0x00000000...Definitely not correct.
Thanks for all your help.
|
|
|
|
|
If NetWkstaGetInfo() is failing, have you called GetLastError() .
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
GetLastError returns 0...I've never used it before, but I understand what it does.
I think I might've found out why I'm not able to obtain network information. I tried using the nslookup command in cmd, and it tells me that it can't find server name for my IP.
Really, I don't think my router and computer are that screwed up.
|
|
|
|
|
hxhl95 wrote: GetLastError returns 0
Which indicates that NetWkstaGetInfo() is not failing. That is, of course, assuming you are calling it correctly.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
LPWKSTA_INFO_100 netinfo = NULL;<br />
PDNS_RECORD dnsRecord;<br />
if (NetWkstaGetInfo(NULL,100,(LPBYTE*)netinfo)!=NERR_Success){<br />
DWORD anError=GetLastError();<br />
CString errormsg="Error: Unable to obtain network information. Error code ";<br />
errormsg+=stringify(anError).c_str();<br />
MessageBox(errormsg,"Error",MB_OK | MB_ICONWARNING);<br />
return;<br />
}<br />
<br />
if (!DnsQuery(netinfo->wki100_langroup, DNS_TYPE_MX, DNS_QUERY_STANDARD, NULL, &dnsRecord, NULL)){<br />
MessageBox("Error: Unable to obtain local SMTP server","Error",MB_OK | MB_ICONWARNING);<br />
return;<br />
}<br />
<br />
m_smtpserver=dnsRecord->Data.MX.pNameExchange;<br />
UpdateData();<br />
DnsRecordListFree(dnsRecord,DnsFreeRecordList);<br />
NetApiBufferFree(netinfo);
I even debugged it, and after the NetWkstaGetInfo call, netinfo points at 0x00000000.
|
|
|
|
|
hxhl95 wrote: if (NetWkstaGetInfo(NULL,100,(LPBYTE*)netinfo)!=NERR_Success){
DWORD anError=GetLastError();
So at this point right here, anError is equal to 0 ?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Nevermind. Solved it. I was missing an & before the netinfo, like this: NetWkstaGetInfo(NULL,100,(LPBYTE*)&netinfo) . I wonder why though.
Although NetWkstaGetInfo is returning NERR_Success now, I am still having trouble. After the NetWkstaGetInfo call, netinfo->wki100_langroup is simply "H". I know that since I put MessageBox(netinfo->wki100_langroup) right after the NetWkstaGetInfo call.
So with the "domain" being H, the DnsQuery call fails.
Any pointers? Thanks a lot for your help.
|
|
|
|
|
hxhl95 wrote: After the NetWkstaGetInfo call, netinfo->wki100_langroup is simply "H".
Which is what normally happens when Unicode is confused with ANSI. Look at netinfo->wki100_langroup in the debug window.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
001570C8 48 00 4F 00 4D 00 45 00 00 00 AD BA D2 70 15 00 A8 70 15 00 D4 70 15 00 00 00 00 00 0D F0 AD BA 4C H.O.M.E...??..+..?.......??
0x001570C8 is where netinfo->wki100_langroup is. I doubt that my local domain is "HOME". I was expecting something like shawcable.net.
And how would I convert unicode to ANSI? I haven't a clue as to what LMSTR is, and it's not on MSDN.
Thanks again for your help.
|
|
|
|
|
Try using the ,su sumbol in the debug watch window.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|