Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

NtOpenSymbolicLinkObject (ntdll)
 
.
Summary
Opens an existing symbolic link.

C# Signature:

[DllImport("ntdll.dll")]
public static extern int NtOpenSymbolicLinkObject(
   out SafeFileHandle LinkHandle,
   uint DesiredAccess,
   ref OBJECT_ATTRIBUTES ObjectAttributes);

User-Defined Types:

OBJECT_ATTRIBUTES

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

cf. NtOpenDirectoryObject

Tips & Tricks:

Please add some!

Sample Code:

static string GetSymbolicLinkTarget(string name)
{
   SafeFileHandle h;
   var attr = new OBJECT_ATTRIBUTES(name, 0);
   var st = Win32.NtOpenSymbolicLinkObject(
     out h, 0x80000000/*GENERIC_READ*/, ref attr);
   if (st < 0) return null;

   int len;
   var buf = new UNICODE_STRING(new string(' ', 512));
   st = Win32.NtQuerySymbolicLinkObject(h, ref buf, out len);

   h.Dispose();
   if (st < 0) return null;
   return buf.ToString();
}

cf. NtQuerySymbolicLinkObject

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions