| RE: [aus-dotnet] DllImport |
- From: Bill McCarthy
- Subject: RE: [aus-dotnet] DllImport
- Date: Sun, 29 Jan 2006 19:37:44 -0800
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Yep, DllImport is for accessing unmanaged functions. (you can also use the shorter Declare syntax in VB) As to why aren't there wrappers for everything, well two reasons. First, it would take a long long time. Even Vista had to scale back on the plans for managed code. If you look at the platform SDK you quickly realize how massive such a task would be. And secondly, there is not always a nice type safe abstraction. A classic example is SendMessage. The number of overloads gets incredibly ugly if you try to provide a type safe wrapper for that in all it's uses, so instead the tendency is to move away from trying to expose low level functions, providing higher level abstractions where possible. Somewhere in the midst of that the AD stuff fell between the cracks ;) > -----Original Message----- > From: peter@xxxxxxxxxxx [mailto:peter@xxxxxxxxxxx] On Behalf > Of Stephen Price > Sent: Monday, January 30, 2006 1:50 PM > To: dotnet@xxxxxxxxxxx > Subject: [aus-dotnet] DllImport > > I'm looking at some code to do with impersonation and a > nagging question popped up (its done it before so here i am > asking why). > > Why do you use DllImport? I understand what it does... ie > allows you to use methods in a dll, but what i don't quite > get is why is this not part of some .net namespace? Is this > how you access unmanaged code? (Is that the right name for > it? code outside of .net is not managed by the framework > right?) I would have thought the framework would have had > somekind of wrapper for OS level stuff. I mean it has it for > accessing files and memory streams etc, why not AD? > > Seeking illumination. :) > > Cheers, > > Stephen > > > http://support.microsoft.com/default.aspx?scid=KB;en-us;q306158 > > [DllImport("advapi32.dll")] > public static extern int LogonUserA(String lpszUserName, > String lpszDomain, > String lpszPassword, > int dwLogonType, > int dwLogonProvider, > ref IntPtr phToken); > [DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError=true)] > public static extern int DuplicateToken(IntPtr hToken, > int impersonationLevel, > ref IntPtr hNewToken); > _________________ You are a part of the Ausralian "dotnet" mailing list. To unsubscribe send "unsubscribe dotnet" or to re-subscribe send "subscribe dotnet" in the body of the email to: imailsrv@xxxxxxxxxxx List Managed by www.stanski.com and Proudly Sponsored by www.ico.com.au
(Click here for more information on the aus-dotnet mailling list)
- Prev by Date: Re: [aus-dotnet] [OT] Tip: Don't go offline for 4 days in a row
- Next by Date: RE: [aus-dotnet] DllImport
- Previous by thread: RE: [aus-dotnet] DllImport
- Next by thread: RE: [aus-dotnet] DllImport
- Index(es):
