Discussing the nuts and bolts of software development

Friday, January 11, 2008


time_t fun!

"When using Visual Studio 2005 and later, the time_t datatype defaults to an 8-byte datatype, not the 4-byte datatype used for the LeaseObtained and LeaseExpires members on a 32-bit platform. To properly use the IP_ADAPTER_INFO structure on a 32-bit platform, define _USE_32BIT_TIME_T (use -D _USE_32BIT_TIME_T as an option, for example) when compiling the application to force the time_t datatype to a 4-byte datatype." — from MSDN Library

So when you are calling functions such as GetAdaptersInfo on a 32 bit machine you need to take such things into account.

ULONG ulLen = 0;
time_t t1;
time_t t2;
CWinErr err;

err = GetAdaptersInfo(NULL, &ulLen); // call with NULL to get size required

// At this point ulLen==640 but the IP_ADAPTER_INFO I compiled is 648 bytes because
// the two time_t members, IP_ADAPTER_INFO::LeaseObtained and IP_ADAPTER_INFO::LeaseExpires
// are 8-byte each.

// Adding the following assert helped us locate a problem
// ASSERT(ulLen >= sizeof(IP_ADAPTER_INFO));

pAdptInfo = (IP_ADAPTER_INFO*)malloc(ulLen);

err = GetAdaptersInfo(pAdptInfo, &ulLen); // Iphlpapi.dll on 32 bit machine uses 4-byte time_t

if (pAdptInfo && err == ERROR_SUCCESS)
t1 = pAdptInfo->LeaseObtained;
t2 = pAdptInfo->LeaseExpires; // Craps out with access violation here because this
// member is actually the last 8 bytes of the struct
// which I haven't allocated in with my malloc call.

Thanks for the warning MS! Now people will probably argue that the warning is in the IP_ADAPTER_INFO MSDN page or I that I should have read this page but I'm not converting my application to 64 bit, I was simply converting my VS2003 solution to VS2005!

Labels: , ,

As for me, on https://paperovernight.com/blog/research-paper-introduction you can read really useful information about writing a research paper introduction. It will help you to get a high grade
This is an informative post. During my college days, I have used Visual studio for programming. I love to do programming with this. Visual Studio is probably the most serious IDE of the planet & the best software ever made by Microsoft. It does every single thing very nicely what it was made for. Once again thank you for sharing this information.

Follow my website link Write my Essay
I try to follow all the news in the field of information technology development. Most of all I like to blow away scientific conferences. I have time for this thanks to cooperation with https://supreme-thesis.com/articles/buy-article-writing/
The jackets that we sell are replicas of the coats worn by top television celebrities because it is a growing trend to copy them when it comes to fashion. These celebrities have really become the trendsetters. This leisure was hitherto in reach of only the rich and the rest could only dream about it. But now these jackets are available for all people who want to buy them because of our affordable prices. So we welcome you to come and buy celebrity jackets of excellent quality and know more about us and our products!

A bathtub, also known simply as a bath or tub, is a container for holding water in which a person or animal may bathe.
baby bath tub supplier
Put more information on your website like this one, I really like these types of blogs. I am also wanted to write blog kindly guide me if my topic is China load haul dump
then what should I do first and how will I create new and unique content on this topic
It should be noted that Latvia, Lithuania and Estonia joined the Schengen area in 2007 and they provide great opportunities for obtaining temporary residence permits through investment. For example, you can obtain a residence permit in Latvia for up to 5 years by investing at least 250,000 euros in real estate or at least 280,000 euros in the subordinated capital of a Latvian credit institution (more details here). Together with the main investor, a residence permit can be obtained by his spouse and minor children. The process of obtaining a temporary residence permit takes from 1 to 3 months. https://www.baltic-legal.com/legal-services-eng.htm
thanks for giving that type of information. Really enjoyed this blog post. Really looking forward to reading more. Much obliged.
That a nice blog for. Like, when I started receiving errors for my mini film project through word press. I even had to opt for the plagiarism free finance thesis to guide me the regulations for if a bought address book works poorly, and the consequences the developers have to face, Luckily, it all worked out just fine.
Free time for entertainment, but at first I had no preparation and I didn’t want to study, but then I found assignment writing help, where any work is done perfectly and, most importantly, competently and quickly
Yo students! Are you running late on your assignment? Get matched with a pro who can do it fast here. All paper experts on our platform https://rankmywriter.com/essaymasters-co-uk-review respect deadlines and will work on your work swiftly. Your paper guru will complete your paper within the timeline you specify or, better yet, before it lapses.
It should be noted that Latvia, Lithuania and Estonia joined the Schengen area in 2007 and they provide great opportunities for obtaining temporary residence permits through investment.apfs install

I've taken Law Essay Writing Service UK & found then quite great for writing what I actually need. It was like they just convey my thoughts in the most engaging manner
When starting a company, people often believe they need a particular set of skills. Many individuals could be interested in starting an internet company; after all, who wouldn't want to be their boss, choose their hours, and be responsible for their financial success? philadelphia SEO expert
This comment has been removed by the author.
I visit interesting blogs every day. I like reading cool articles. If you find such an interesting blog like this write to me https://profit.ly/user/jennyluray/blog/the-legal-research-process.

Good technical post. Thanks for sharing the coding. Keep sharing more technical blogs. Protection Order Virginia
Thanks for sharing this crucial tip on handling time_t datatype in Visual Studio 2005 and later. Your experience with GetAdaptersInfo highlights an important consideration for 32-bit machines. Great heads up
Civil Protective Order In New Jersey
I love this content, thanks for uploading it.
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?