Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my code

XML
//part of the idle stuff
        [StructLayout(LayoutKind.Sequential)]
        struct LASTINPUTINFO
        {
            public static readonly int SizeOf = Marshal.SizeOf(typeof(LASTINPUTINFO));

            [MarshalAs(UnmanagedType.U4)]
            public UInt32 cbSize;
            [MarshalAs(UnmanagedType.U4)]
            public UInt32 dwTime;
        }

uint idleTime = 0;
            LASTINPUTINFO lastInputInfo = new LASTINPUTINFO();

            //int y = Convert.ToInt32(lastInputInfo);
            uint y = Convert.ToUInt32(lastInputInfo);
            lastInputInfo.cbSize = Marshal.SizeOf(y);
            lastInputInfo.dwTime = 0;</pre>

i used both those methods by the way because it can't make up its mind and this is my error


<code>Error 1 Cannot implicitly convert type 'int' to 'uint'. An explicit conversion exists (are you missing a cast?) Z:\UnHidden\UnHidden\Form1.cs 48 36 UnHidden</code>

and i get the same error with each of those convert codes, can some one please tell me whats happening and how i can possibly fix this?
Posted
Updated 14-Jul-16 1:31am

1 solution

The error is pretty explicit, and does tell you what to do: either change the definition to Int32, or cast the values to UInt32:
C#
lastInputInfo.cbSize = (UInt32) Marshal.SizeOf(y);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900