473,569 Members | 2,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FieldOffset on 64bit OS

I've been using INPUT as declared below. However, I get warnings about
this being incompatible with a 64bit OS. I have no 64bit OS to test
on. However, is it true that the union in the INPUT declaration below
would need to line on an 8byte boundary for a 64bit OS? And should I
just do this with #if? #if 64bitosblah FieldOffset(8) #else
FieldOffset(4)?

[DllImport("User 32.dll", SetLastError = true)]
public static extern uint SendInput(uint nInputs, INPUT[] pInputs,
int cbSize);

[StructLayout(La youtKind.Sequen tial)]
public struct MOUSEINPUT
{
public int dx;
public int dy;
public uint mouseData;
public uint dwFlags;
public uint time;
public IntPtr dwExtraInfo;
}

[StructLayout(La youtKind.Sequen tial)]
public struct KEYBDINPUT
{
public ushort wVk;
public ushort wScan;
public uint dwFlags;
public uint time;
public IntPtr dwExtraInfo;
}

[StructLayout(La youtKind.Sequen tial)]
public struct HARDWAREINPUT
{
public uint uMsg;
public ushort wParamL;
public ushort wParamH;
}

[StructLayout(La youtKind.Explic it)]
public struct INPUT
{
[FieldOffset(0)]
public int type;
[FieldOffset(4)]
public MOUSEINPUT mi;
[FieldOffset(4)]
public KEYBDINPUT ki;
[FieldOffset(4)]
public HARDWAREINPUT hi;
}
Nov 3 '08 #1
2 3518
On Mon, 03 Nov 2008 13:54:07 -0800, not_a_commie <no********@gma il.com>
wrote:
I've been using INPUT as declared below. However, I get warnings about
this being incompatible with a 64bit OS. I have no 64bit OS to test
on. However, is it true that the union in the INPUT declaration below
would need to line on an 8byte boundary for a 64bit OS?
I don't know the exact answer. But it _could_. On Intel architecture,
unaligned data simply produces severe speed problems. But on other
architectures, it's actually mandatory that the data be aligned to the
word size. 8-byte words have to be on a byte boundary that's a multiple
of 8.

..NET _might_ enforce that, if it's trying to take into account those other
architectures. Or, it might provide some sort of run-time support to hide
alignment exceptions on hardware that requires aligned accesses.

When you say "I get warnings", what kind of warnings? From whom do you
get them? If it's the compiler actually emitting a warning, I think you
should definitely take those seriously (and you should be more explicit
about the warning in your question). If it's some random person telling
you that, then you'll have to consider how reliable that person is, or
perhaps do some Googling to see if you can turn additional information up.

Pete
Nov 4 '08 #2
On Nov 3, 1:54*pm, not_a_commie <notacom...@gma il.comwrote:
* * * * * * * * [DllImport("User 32.dll", SetLastError =true)]
* * * * * * * * public static extern uint SendInput(uint nInputs, INPUT[] pInputs,
int cbSize);
Just an offhand thought, but it could be this reference to
"User32.dll " which (based on its name) appears to be a 32-bit library,
and thus wouldn't work on a 64-bit OS (just a thought).

-Ryan
Nov 4 '08 #3

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

Similar topics

3
3230
by: Christian McArdle | last post by:
REQUEST FOR DISCUSSION (RFD) unmoderated group comp.os.ms-windows.programmer.64bit This is a formal Request For Discussion (RFD) to create comp.os.ms-windows.programmer.64bit as an unmoderated world-wide Usenet newsgroup dedicated to the discussion of Microsoft Windows 64-bit programming. This is not a Call for Votes (CFV); you cannot vote...
4
13897
by: Chua Wen Ching | last post by:
Hi there, I had a union in C: typedef union TagMessage { struct { unsigned char avalue; unsigned char bvalue; } a;
11
13285
by: Vijay Chegu | last post by:
I have built a 64bit ATL COM dll. When i register the dll on IA64 windows Enterprise server 2003, i get following error. DllRegisterServer in mydll.dll failed. Return code was : 0x80020009 The command i am using to register the dll is
4
5905
by: Danny Mavromatis | last post by:
I'm trying to set up a structure using unions (fieldoffset) and I'm running into a problem. When I try to setup a union of data array or message type, I get the following error: System.TypeLoadException: Could not load type 'Test.Message' from assembly 'Test, Version=1.0.2228.19435, Culture=neutral, PublicKeyToken=null' because it contains...
3
2502
by: Frank Uray | last post by:
Hi all I have written a WindowsService in C# 2005. I am running this service on a 64bit Windows Server 2003 and I like to run some Interop.Excel within this service. It seams that Interop does not run in 64bit mode ... I have tried to compile the service as x86 but it does not help, the service is still running in 64bit mode ...
4
5713
by: mike | last post by:
I have found that orig tested 64 bit on our 64bit windows 2003 server...about 1 year ago...and company decided to use sql 32 bit on the 64bit os my question and any information is very welcome is there any things in need to know about awe with memory above 4g ...whilst using 32 bit sql on a 64bit os i want to increase the memory on the...
2
2984
by: Steve Richter | last post by:
I have a struct that uses LayoutKind.Explicit to redefine bytes within the struct: public struct PointerStoredValue { public int LayoutId; public int HeapId ;
1
1958
by: GaryDean | last post by:
We have been developing all of our .net applications on 32 bit windows using 32 bit SQL Server. We are being asked to now deploy to servers running 64bit windows and 64bit SQL Server. Are there issues? Differences? Should we switch our dev environment to 64bit. What is the advantage of going with 64 bit servers other than being able to...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
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...
1
7676
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7974
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...
0
6284
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...
0
5219
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...
0
3653
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...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
938
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...

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.