Red Gate forums :: View topic - Problem with call a WinAPI Function Dhcpcsvc.dll DhcpRequest
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
PInvoke.Net
PInvoke.Net forum

Problem with call a WinAPI Function Dhcpcsvc.dll DhcpRequest

Search in PInvoke.Net forum
Post new topic   Reply to topic
Jump to:  
Author Message
live2



Joined: 23 Feb 2008
Posts: 1

PostPosted: Sat Feb 23, 2008 4:00 pm    Post subject: Problem with call a WinAPI Function Dhcpcsvc.dll DhcpRequest Reply with quote

Problem with call a WinAPI Function Dhcpcsvc.dll DhcpRequestParams

Error Message Sorry i have it only in German
Quote:

Ein Aufruf an die PInvoke-Funktion "WindowsApplication1!WindowsApplication1.Form1::DhcpRequestParams" hat das Gleichgewicht des Stapels gestört. Wahrscheinlich stimmt die verwaltete PInvoke-Signatur nicht mit der nicht verwalteten Zielsignatur überein. Überprüfen Sie, ob die Aufrufkonvention und die Parameter der PInvoke-Signatur mit der nicht verwalteten Zielsignatur übereinstimmen.



Code:

        const byte DHCPCAPI_REQUEST_PERSISTENT = 0x01;
        const byte DHCPCAPI_REQUEST_SYNCHRONOUS = 0x02;
        const byte DHCPCAPI_REQUEST_ASYNCHRONOUS = 0x04;
        const byte DHCPCAPI_REQUEST_CANCEL = 0x08;
        const byte DHCPCAPI_REQUEST_MASK = 0x0F;

        public struct DHCPCAPI_CLASSID
        {
            public int Flags;
            public byte Data;
            public int nBytesData;
        }

        public struct DHCPCAPI_PARAMS
        {
            public int Flags;
            public int OptionId;
            public bool IsVendor;
            public byte Data;
            public int nBytesData;
        }

        public struct DHCPCAPI_PARAMS_ARRAY
        {
            public int nParams;
            public DHCPCAPI_PARAMS Params;
        }

        [DllImport("Dhcpcsvc.dll")]
        public static extern int DhcpRequestParams(uint Flags, IntPtr Reserved, [MarshalAs(UnmanagedType.LPWStr)] string AdapterName, DHCPCAPI_CLASSID ClassId, DHCPCAPI_PARAMS_ARRAY SendParams, ref DHCPCAPI_PARAMS_ARRAY RecdParams, string Buffer, ref uint pSize, [MarshalAs(UnmanagedType.LPWStr)] string RequestIdStr);

        private void button1_Click(object sender, EventArgs e)
        {

            DHCPCAPI_PARAMS DhcpApiHostNameParams = new DHCPCAPI_PARAMS();
            DhcpApiHostNameParams.Flags = 0;
            DhcpApiHostNameParams.OptionId = 66;
            DhcpApiHostNameParams.IsVendor = false;
            DhcpApiHostNameParams.Data = new byte();
            DhcpApiHostNameParams.nBytesData = 0;

            DHCPCAPI_PARAMS_ARRAY SendParams = new DHCPCAPI_PARAMS_ARRAY();
            SendParams.nParams = 0;
            SendParams.Params = new DHCPCAPI_PARAMS();

            DHCPCAPI_PARAMS_ARRAY RecdParams = new DHCPCAPI_PARAMS_ARRAY();
            RecdParams.nParams = 1;
            RecdParams.Params = DhcpApiHostNameParams;

            IntPtr Reserved = new IntPtr();
            DHCPCAPI_CLASSID ClassId = new DHCPCAPI_CLASSID();
            uint pSize = 1;

            DhcpRequestParams(1, Reserved, "VMWare Accelerated AMD PCNet Adapter", ClassId, SendParams, ref RecdParams, "", ref pSize, "1");
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group