473,718 Members | 1,964 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1250
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:rOdGr40LMP U3-pn2-MSB6WBRDXf5J@lo calhost...
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
15225
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 Personal disk from the SQL Server 2000 Enterprise kit as this is reported here on the MSDN web site to be the version that is supported on Windows XP. In fact so many of you kind people confess to having succeeded in doing it. I have tried...
7
3211
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 think the username can be read with user.identity.name.
7
2638
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: System.ArgumentException occured in System.Windows.Forms.dll
1
3454
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 going wrong. The program has been written to do the following tasks: - Select remote server - Select from two specific services
0
3937
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 - Select from two specific services - Check the status of the server
4
3158
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 further away, completely leaving the selector box area. Any ideas? VS 2003 and VB.Net This is a simple application at the moment but the form is inherited from a
2
11732
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 another CD, and gets caught in a loop when I try to delete it! It mentions MS.net frame error # 1706. The "details" code follows...hope someone can help me to either fix it or get out of the loop! I tried running "Windows Registry Repair Pro"...but no help...
1
7842
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 am note sure what to do because all propertiers work, except the System.Data.DataColumn.. I didn't write any code by hand and used the visual studio to set the properties..
0
30236
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 a comprehensive list of all autostart locations for Windows OSes: NOTE : These are some abbreviations used in this list. Please note them carefully: HKCU = HKEY_CURRENT_USER HKLM = HKEY_LOCAL_MACHINE
0
8827
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9053
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7987
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5971
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4481
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4741
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3182
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2122
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.