Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Know the theory of managed and unmanaged code but how to know that dll which im using is managed or unmanaged
kernel32.dll
this dll im using in my project i want to know that dll is managed or unmanaged

What I have tried:

[DllImport("advapi32.dll", EntryPoint = "CreateProcessAsUser", SetLastError = true, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public extern static bool CreateProcessAsUser(IntPtr hToken, String lpApplicationName, String lpCommandLine, ref SECURITY_ATTRIBUTES lpProcessAttributes,
    ref SECURITY_ATTRIBUTES lpThreadAttributes, bool bInheritHandle, int dwCreationFlags, IntPtr lpEnvironment,
    String lpCurrentDirectory, ref STARTUPINFO lpStartupInfo, out PROCESS_INFORMATION lpProcessInformation);
Posted
Updated 11-Jul-17 3:10am

You must know from which source the dll is. In the Micorsoft documentation you can read that it belongs to Windows.

Here is also some detailed explanation of the usage of CreateProcessAsUser with the net-framework. Read it carefully!!!
 
Share this answer
 
You can't tell without knowing from the name, or actually "looking" at the contents.

But ... if it needs a DllImport decoration, then it's not managed - DllImport is the mechanism for accessing unmanaged DLLs.

And kernel32.dll is definitely unmanaged - it's part of Windows.

If you want to check, try to add the file as a reference to your project - if it adds ok, it's managed. If it doesn't, it's unmanaged (or corrupt).
 
Share this answer
 
The way to know whether an assembly is managed or unmanaged relates to something called the PE Header (Portable Executable). This is a standard file header for binary Windows executable code (be it an exe or a dll). The details about whether or not it's managed or not is contained in this header. There's an excellent set of articles on this format starting here Anatomy of a .NET Assembly - PE Headers - Simple Talk[^]. If I were you. I'd have a read of this.
 
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