473,378 Members | 1,152 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

c++ and windows api

This might be a stupid question but the answer evades me at this moment. You
know how in C/C++ compiler settings influence the size of
structures/classes. How come the windows api (which often takes pointers to
structures as parameters) still works independently of my compiler settings?

Thanks
Jul 23 '05 #1
2 1241
Hello B.C.,

On Fri, 11 Mar 2005 16:43:23 UTC, "B.C." <do*******************@xyz-abc.com>
wrote:
This might be a stupid question but the answer evades me at this moment. You
know how in C/C++ compiler settings influence the size of
structures/classes. How come the windows api (which often takes pointers to
structures as parameters) still works independently of my compiler settings?

Thanks


The pointers are a certain, agreed upon size. The structures that they
point
to could have problems with your code if your code did not obey the packing
options expected by the Windows API. There are several ways to control
packing
in C and C++. One is by the compiler settings and that controls the packing
options for the entrire compile session. Another method is to use the
"#pragma pack" option. This can be used to set a desired packing option and
later restore the packing option to the default level. Good communications
code that depends on the packing options of a structure will include these
packing options around the critical structures in its headers. If you look
at the headers that define such critical Windows API Structures, you will
find where they have enclosed those structures with the desired packing
options. This is no different than how any other API could achieve the
same goal.

I hope that jogs your memory for you.

David
Jul 23 '05 #2
Yes, it makes sense. I took a look at some h files and you are right, some
of the files include pshpack4.h which makes use of the #pragama pack option

Thank you

Thank you
"David" <Fl************@United.Com> wrote in message
news:rOdGr40LMPU3-pn2-MSB6WBRDXf5J@localhost...
Hello B.C.,

On Fri, 11 Mar 2005 16:43:23 UTC, "B.C." <do*******************@xyz-abc.com> wrote:
This might be a stupid question but the answer evades me at this moment. You know how in C/C++ compiler settings influence the size of
structures/classes. How come the windows api (which often takes pointers to structures as parameters) still works independently of my compiler settings?
Thanks
The pointers are a certain, agreed upon size. The structures that they
point
to could have problems with your code if your code did not obey the

packing options expected by the Windows API. There are several ways to control
packing
in C and C++. One is by the compiler settings and that controls the packing options for the entrire compile session. Another method is to use the
"#pragma pack" option. This can be used to set a desired packing option and later restore the packing option to the default level. Good communications code that depends on the packing options of a structure will include these
packing options around the critical structures in its headers. If you look at the headers that define such critical Windows API Structures, you will
find where they have enclosed those structures with the desired packing
options. This is no different than how any other API could achieve the
same goal.

I hope that jogs your memory for you.

David

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ken Lindner | last post by:
I have a need to become familiar with SQL Server 2000 for work. Needless to say I am new to SQL Server any version, but not IT in general. My employer has provided me with the SQL Server 2000...
7
by: lvpaul | last post by:
Hallo ! I am using IIS-Windows-Authentication in my intranet (web.config <authentication mode="Windows" /> <identity impersonate="true" /> How can I get the users (client) IP-Address ? I...
7
by: Tyler Foreman | last post by:
Hello, I have a strange problem that occurs every so often in my application. It usually takes place when I hide one form and activate another. What happens is I get the following exception:...
1
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. I'm having trouble getting the code that I've written to work, can anyone shed some light as to where I'm...
0
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. The program I'm trying to develop needs to be able to do the following: - Select remote server -...
4
by: Rod Gill | last post by:
Hi, I have a form that when opened in the designer appears of the screen. The form selector can't be dragged (or resized) and if I scroll right and down to centralise it the form simply jumps...
2
by: sambo251 | last post by:
After running a few updates I get this very annoying "Windows Installer" error #1706 that will ne go away! It keeps saying that it cannot find the file "instantsharedevices.msi", that it is on...
1
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I...
0
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: List of autostart locations Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list all the autostart locations for windows? Ans: Here is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.