I would like to move a file from Windows Mobile to a specific folder in Windows. The file in the mobile device is into the My Documents path.
The device is connected to the WiFi network, and the folder shared in windows is called "folder".
How could I do, I tried this but doesn't work:
var f= System.Enviroment.GetFolderPath(System.Enviroment.SpecialFolder.Personal);
FileInfo fi = new FileInfo(f.ToString() + #"\file.txt");
fi.CopyTo(#"\\MYPERSONAL-PC\folder",true);
the error is :
in System.IO.__Error.WinIOError(Int32 errorCode, String str)
in System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite)
in System.IO.FileInfo.CopyTo(String destFileName, Boolean overwrite)
in Project.MainForm.SaveButton_Click(Object sender, EventArgs e)
in System.Windows.Forms.Control.OnClick(EventArgs e)
in System.Windows.Forms.Button.OnClick(EventArgs e)
in System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)
in System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
in Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
in System.Windows.Forms.Application.Run(Form fm)
in Project.Program.Main()
I also tried to use WNetAddConnection3, but still the same the connection to the network resource is ok, but return me always the same the code is here:
[StructLayout(LayoutKind.Sequential)]
internal struct NetResource
{
public uint dwScope;
public uint dwType;
public uint dwDisplayType;
public uint dwUsage;
[MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)]
public string lpLocalName;
[MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)]
public string lpRemoteName;
[MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)]
public string lpComment;
[MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)]
public string lpProvider;
}
[DllImport("coredll.dll")]
private static extern int WNetAddConnection3(IntPtr hWndOwner,
ref NetResource lpNetResource, string lpPassword, string lpUserName, int dwFlags);
[DllImport("coredll.dll")]
static extern int WNetCancelConnection2(string lpName, Int32 dwFlags, bool bForce);
var f= System.Enviroment.GetFolderPath(System.Enviroment.SpecialFolder.Personal);
NetResource logsResource = new NetResource();
logsResource.lpLocalName = "logs";
logsResource.lpRemoteName = #"\\MYPERSONAL-PC\folder";
logsResource.dwType = 0x1;
logsResource.dwScope = 0;
logsResource.dwUsage = 0;
logsResource.dwDisplayType = 0;
//try to connect the network resource
WNetAddConnection3(new IntPtr(0), ref logsResource, #"pass", #"dom\user", 0);
FileInfo fi = new FileInfo(f.ToString() + #"\file.txt");
**fi.CopyTo(#"\\MYPERSONAL-PC\folder", true);**
A few things to try:
Can you connect to the file share from a laptop or other PC on the wireless network? I want to verify it's not a configuration or authentication problem.
Assuming #1 works: try replacing MYPERSONAL-PC with the IP address of the PC?
Assuming #1 works, but #2 does not: try to P/Invoke WNetAddConnection3 to make a local connection to a network resource (like mapping a network drive) and copy to that.
I would set the redir registry entry RegisterFSRoot to 1 and see the \Network folder on the device: http://msdn.microsoft.com/en-us/library/aa922326.aspx. Then you can use the file copy function to copy to \Network\. Where shared folder is the one you mapped from the sharing server. If you did not Connect to the share using mobile File Explorer, you can use WNetAddConnection3 to add the connection http://msdn.microsoft.com/en-us/library/aa916067.aspx and http://msdn.microsoft.com/en-us/library/aa917445.aspx. When usig C# you have to p/invoke the APIs: http://www.pinvoke.net/default.aspx/mpr.wnetaddconnection3 (replace mpr.dll with coredll.dll)
Related
Is it possible to send Toast notifications from console application using ToastNotificationManager ?
I know that it is possible to send Toast notifications from Windows Universal app:
var toast = new ToastNotification(doc);
ToastNotificationManager.CreateToastNotifier().Show(toast);
*doc - Toast stored in XML string
To use ToastNotificaionManager I need Windows.UI.Notifications library which I can't reference in console application project.
The library I mentionet before is actualy used by WinRT. Is it possible to use WinRT APIs in Windows console application ?
At first you need to declare that your program will be using winRT libraries:
Right-click on your yourProject, select Unload Project
Right-click on your yourProject(unavailable) and click Edit yourProject.csproj
Add a new property group:<targetplatformversion>8.0</targetplatformversion>
Reload project
Add reference Windows from Windows > Core
Now you need to add this code:
using Windows.UI.Notifications;
and you will be able to send notifications using this code:
var toast = new ToastNotification(doc);
ToastNotificationManager.CreateToastNotifier().Show(toast);
Reference: How to call WinRT APIs in Windows 8 from C# Desktop Applications - WinRT Diagram
I ran into some problems here with Evaldas B's Code I was missing a string.
(Where It Says Need String Here)
.CreateToastNotifier(<needed a string here>).Show(toast);
warning I am kind of new to C# so my code probably sucks- but it does work and is pretty simplistic and that's more than I can say for most solutions I have found
Also I was having a hell of a time getting the xml document to read. I was fighting with System.xml (I think) and Windows.Data.Dom.Xml (also not completely sure).
In the end I settled on making them hard coded strings for my example file and used a switch statement to switch between them.
I have found a ton of people, looking for the solution that I have come up with, on stack overflow. It seems use of the toast notification system with console or background applications would be super useful, and the documentation that surrounds the toast notification system with windows applications all suggest that it needs to be used with an application. The Action Center is super useful for notifications vrs the NotificationTray/NotifyIcon route. I have not found a full solution anywhere else on the web. Here is example code.
/*
At first you need to declare that your program will be using winRT libraries:
1. Right click on your yourProject, select Unload Project
2. Right click on your youProject(unavailable) and click Edit yourProject.csproj
3. Add a new property group:<TargetPlatformVersion>8.0</TargetPlatformVersion>
4. Reload project
5. Add referece Windows from Windows > Core
*/
using System;
using Windows.Data.Xml.Dom;
using Windows.Storage;
using Windows.Storage.Streams;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Notifications;
namespace ConsoleApplication6
{
public class NewToastNotification
{
public NewToastNotification(string input, int type)
{
string NotificationTextThing = input;
string Toast = "";
switch (type)
{
case 1:
{
//Basic Toast
Toast = "<toast><visual><binding template=\"ToastImageAndText01\"><text id = \"1\" >";
Toast += NotificationTextThing;
Toast += "</text></binding></visual></toast>";
break;
}
default:
{
Toast = "<toast><visual><binding template=\"ToastImageAndText01\"><text id = \"1\" >";
Toast += "Default Text String";
Toast += "</text></binding></visual></toast>";
break;
}
}
XmlDocument tileXml = new XmlDocument();
tileXml.LoadXml(Toast);
var toast = new ToastNotification(tileXml);
ToastNotificationManager.CreateToastNotifier("New Toast Thing").Show(toast);
}
}
class Program
{
static void Main(string[] args)
{
NewToastNotification Window = new NewToastNotification("Yes",1);
}
}
}
1) For a toast notification to appear using a console or Desktop application, your application must have a shortcut on the start menu.
2) For an application to have a shortcut icon(not tile icon) in the start menu of Windows, your app must have an AppId.
To create a short cut for you you application create a new class named ShellHelpers.cs and Paste this code in it.
using System;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;
using MS.WindowsAPICodePack.Internal;
namespace DesktopToastsSample.ShellHelpers
{
internal enum STGM : long
{
STGM_READ = 0x00000000L,
STGM_WRITE = 0x00000001L,
STGM_READWRITE = 0x00000002L,
STGM_SHARE_DENY_NONE = 0x00000040L,
STGM_SHARE_DENY_READ = 0x00000030L,
STGM_SHARE_DENY_WRITE = 0x00000020L,
STGM_SHARE_EXCLUSIVE = 0x00000010L,
STGM_PRIORITY = 0x00040000L,
STGM_CREATE = 0x00001000L,
STGM_CONVERT = 0x00020000L,
STGM_FAILIFTHERE = 0x00000000L,
STGM_DIRECT = 0x00000000L,
STGM_TRANSACTED = 0x00010000L,
STGM_NOSCRATCH = 0x00100000L,
STGM_NOSNAPSHOT = 0x00200000L,
STGM_SIMPLE = 0x08000000L,
STGM_DIRECT_SWMR = 0x00400000L,
STGM_DELETEONRELEASE = 0x04000000L,
}
internal static class ShellIIDGuid
{
internal const string IShellLinkW = "000214F9-0000-0000-C000-000000000046";
internal const string CShellLink = "00021401-0000-0000-C000-000000000046";
internal const string IPersistFile = "0000010b-0000-0000-C000-000000000046";
internal const string IPropertyStore = "886D8EEB-8CF2-4446-8D02-CDBA1DBDCF99";
}
[ComImport,
Guid(ShellIIDGuid.IShellLinkW),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IShellLinkW
{
UInt32 GetPath(
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile,
int cchMaxPath,
//ref _WIN32_FIND_DATAW pfd,
IntPtr pfd,
uint fFlags);
UInt32 GetIDList(out IntPtr ppidl);
UInt32 SetIDList(IntPtr pidl);
UInt32 GetDescription(
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile,
int cchMaxName);
UInt32 SetDescription(
[MarshalAs(UnmanagedType.LPWStr)] string pszName);
UInt32 GetWorkingDirectory(
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszDir,
int cchMaxPath
);
UInt32 SetWorkingDirectory(
[MarshalAs(UnmanagedType.LPWStr)] string pszDir);
UInt32 GetArguments(
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs,
int cchMaxPath);
UInt32 SetArguments(
[MarshalAs(UnmanagedType.LPWStr)] string pszArgs);
UInt32 GetHotKey(out short wHotKey);
UInt32 SetHotKey(short wHotKey);
UInt32 GetShowCmd(out uint iShowCmd);
UInt32 SetShowCmd(uint iShowCmd);
UInt32 GetIconLocation(
[Out(), MarshalAs(UnmanagedType.LPWStr)] out StringBuilder pszIconPath,
int cchIconPath,
out int iIcon);
UInt32 SetIconLocation(
[MarshalAs(UnmanagedType.LPWStr)] string pszIconPath,
int iIcon);
UInt32 SetRelativePath(
[MarshalAs(UnmanagedType.LPWStr)] string pszPathRel,
uint dwReserved);
UInt32 Resolve(IntPtr hwnd, uint fFlags);
UInt32 SetPath(
[MarshalAs(UnmanagedType.LPWStr)] string pszFile);
}
[ComImport,
Guid(ShellIIDGuid.IPersistFile),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IPersistFile
{
UInt32 GetCurFile(
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile
);
UInt32 IsDirty();
UInt32 Load(
[MarshalAs(UnmanagedType.LPWStr)] string pszFileName,
[MarshalAs(UnmanagedType.U4)] STGM dwMode);
UInt32 Save(
[MarshalAs(UnmanagedType.LPWStr)] string pszFileName,
bool fRemember);
UInt32 SaveCompleted(
[MarshalAs(UnmanagedType.LPWStr)] string pszFileName);
}
[ComImport]
[Guid(ShellIIDGuid.IPropertyStore)]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IPropertyStore
{
UInt32 GetCount([Out] out uint propertyCount);
UInt32 GetAt([In] uint propertyIndex, out PropertyKey key);
UInt32 GetValue([In] ref PropertyKey key, [Out] PropVariant pv);
UInt32 SetValue([In] ref PropertyKey key, [In] PropVariant pv);
UInt32 Commit();
}
[ComImport,
Guid(ShellIIDGuid.CShellLink),
ClassInterface(ClassInterfaceType.None)]
internal class CShellLink { }
public static class ErrorHelper
{
public static void VerifySucceeded(UInt32 hresult)
{
if (hresult > 1)
{
throw new Exception("Failed with HRESULT: " + hresult.ToString("X"));
}
}
}
}
Code for creating a shortcut(This code can be added to the same class where you will be showing the toast)
public bool TryCreateShortcut()
{
String shortcutPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Microsoft\\Windows\\Start Menu\\Programs\\FixSus Toasts Sample .lnk";
if (!File.Exists(shortcutPath))
{
InstallShortcut(shortcutPath);
return true;
}
return false;
}
private void InstallShortcut(String shortcutPath)
{
// Find the path to the current executable
String exePath = Process.GetCurrentProcess().MainModule.FileName;
IShellLinkW newShortcut = (IShellLinkW)new CShellLink();
// Create a shortcut to the exe
DesktopToastsSample.ShellHelpers.ErrorHelper.VerifySucceeded(newShortcut.SetPath(exePath));
DesktopToastsSample.ShellHelpers.ErrorHelper.VerifySucceeded(newShortcut.SetArguments(""));
// Open the shortcut property store, set the AppUserModelId property
IPropertyStore newShortcutProperties = (IPropertyStore)newShortcut;
using (PropVariant appId = new PropVariant(APP_ID))
{
DesktopToastsSample.ShellHelpers.ErrorHelper.VerifySucceeded(newShortcutProperties.SetValue(SystemProperties.System.AppUserModel.ID, appId));
DesktopToastsSample.ShellHelpers.ErrorHelper.VerifySucceeded(newShortcutProperties.Commit());
}
// Commit the shortcut to disk
IPersistFile newShortcutSave = (IPersistFile)newShortcut;
DesktopToastsSample.ShellHelpers.ErrorHelper.VerifySucceeded(newShortcutSave.Save(shortcutPath, true));
}
Now you can create an show a toast
// Get a toast XML template
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText04);
// Fill in the text elements
XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
stringElements[1].AppendChild(toastXml.CreateTextNode("Message" + newMessage));
// Specify the absolute path to an image
string codeWebFolderPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, #"..\..\"));
String imagePath = "file:///" + Path.GetFullPath(codeWebFolderPath+ "Resources\\FixSus.png");
XmlNodeList imageElements = toastXml.GetElementsByTagName("image");
imageElements[0].Attributes.GetNamedItem("src").NodeValue = imagePath;
// Create the toast and attach event listeners
ToastNotification toast = new ToastNotification(toastXml);
toast.Activated += ToastActivated;
toast.Dismissed += ToastDismissed;
toast.Failed += ToastFailed;
// Show the toast. Be sure to specify the AppUserModelId on your application's shortcut!
ToastNotificationManager.CreateToastNotifier(APP_ID).Show(toast);
The APP_ID can be any string. In my case it was "NotificationTest.KEY"
Note: Dont modify the ShellHelper class.
Edit : Follow Evaldas B's answer first then apply this solution.
I have the following problem. I want to open an embedded textfile (agb.txt) using "notepad.exe". I've got the following code:
private void linkLabel4_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
string editorPath = Environment.SystemDirectory + "\\notepad.exe";
var startInfo = new ProcessStartInfo(editorPath)
{
//Start Maximized
WindowStyle = ProcessWindowStyle.Maximized,
Arguments = "agb.txt"
};
//Start notepad.exe (agb.txt)
Process.Start(startInfo);
}
When I start the program and click the Linklabel, Notpad.exe open up but can't find the embedded file (obviously). So is there a kinda 'Workaround'?
What about saving the file to %TEMP% and then simply calling
Process.Start(#"c:\temp\agb.txt");
(this will actually open the file in whatever application is registered to load it)
You can start Nodepad.exe and then "send" the text from the embedded file to it.
Instead of my hardcoded string, you would read the content of the file into a string and then call DoSendMessage(stringWithYourFileContent);
This question and answer is a good resource for reading the content of the embedded file: How to read embedded resource text file
class Program
{
[DllImport("user32.dll", EntryPoint = "FindWindowEx")]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("User32.dll")]
public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
static void Main(string[] args)
{
DoSendMessage("Sending a message, a message from me to you");
}
private static void DoSendMessage(string message)
{
Process notepad = Process.Start(new ProcessStartInfo("notepad.exe"));
notepad.WaitForInputIdle();
if (notepad != null)
{
IntPtr child = FindWindowEx(notepad.MainWindowHandle, new IntPtr(0), "Edit", null);
SendMessage(child, 0x000C, 0, message);
}
}
}
The constant 0x000c of SendMessage is documented here
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632644(v=vs.85).aspx
. The constant says SETTEXT which really means that the text in
notepad will be replaced if you send more than one message using this
constant.
I want to association ".abc" file to my WPF application.
I add the association using this code:
public class FileAssociation
{
static RegistryKey Root
{
get
{
return Registry.CurrentUser;
}
}
// Associate file extension with progID, description, icon and application
public static void Associate(string extension,
string progID, string description, string application)
{
Require.NotNullOrEmpty(extension, "extension");
Require.NotNullOrEmpty(progID, "progID");
Require.NotNullOrEmpty(application, "application");
Require.NotNullOrEmpty(description, "description");
Root.CreateSubKey(extension).SetValue("", progID);
using (var key = Root.CreateSubKey(progID))
{
key.SetValue("", description);
key.CreateSubKey("DefaultIcon").SetValue("", ToShortPathName(application).Quote() + ",0");
key.CreateSubKey(#"Shell\Open\Command").SetValue("", ToShortPathName(application).Quote() + " \"%1\"");
// Tell explorer the file association has been changed
SHChangeNotify(0x08000000, 0x0000, IntPtr.Zero, IntPtr.Zero);
}
}
// Return true if extension already associated in registry
public static bool IsAssociated(string extension)
{
return (Root.OpenSubKey(extension, false) != null);
}
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);
[DllImport("Kernel32.dll")]
private static extern uint GetShortPathName(string lpszLongPath,
[Out] StringBuilder lpszShortPath, uint cchBuffer);
// Return short path format of a file name
private static string ToShortPathName(string longName)
{
StringBuilder s = new StringBuilder(1000);
uint iSize = (uint)s.Capacity;
uint iRet = GetShortPathName(longName, s, iSize);
return s.ToString();
}
}
Note: The Quote() extension method is used just to make string abc to "abc".
Now the file association works fine! I can double click the ".abc" files to open my WPF app.
But the DefaultIcon is not working. The DefaultIcon Registery key is set to "D:\path\to\MyWPFApp.exe",0. The application icon of my WPF app is set to an icon in the properties page (I can see that the icon of MyWPFApp.exe is already changed). What's wrong? Thanks!
BTW: I'm using .NET 4 in Windows 8
You don't need the DefaultIcon entry. The first icon is used by default.
remove it and it should work ^^
If I remove the ToShortPathName (long name is ok with quotes) and
change the Root property returns Registry.ClassesRoot the code works here.
When I click a button on a Windows Forms form, I would like to open a Notepad window containing the text from a TextBox control on the form.
How can I do that?
You don't need to create file with this string. You can use P/Invoke to solve your problem.
Usage of NotepadHelper class:
NotepadHelper.ShowMessage("My message...", "My Title");
NotepadHelper class code:
using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace Notepad
{
public static class NotepadHelper
{
[DllImport("user32.dll", EntryPoint = "SetWindowText")]
private static extern int SetWindowText(IntPtr hWnd, string text);
[DllImport("user32.dll", EntryPoint = "FindWindowEx")]
private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
public static void ShowMessage(string message = null, string title = null)
{
Process notepad = Process.Start(new ProcessStartInfo("notepad.exe"));
if (notepad != null)
{
notepad.WaitForInputIdle();
if (!string.IsNullOrEmpty(title))
SetWindowText(notepad.MainWindowHandle, title);
if (!string.IsNullOrEmpty(message))
{
IntPtr child = FindWindowEx(notepad.MainWindowHandle, new IntPtr(0), "Edit", null);
SendMessage(child, 0x000C, 0, message);
}
}
}
}
}
References (pinvoke.net and msdn.microsoft.com):
SetWindowText: pinvoke | msdn
FindWindowEx: pinvoke | msdn
SendMessage: pinvoke | msdn
Try this out:
System.IO.File.WriteAllText(#"C:\test.txt", textBox.Text);
System.Diagnostics.Process.Start(#"C:\test.txt");
Save the file to disk using File.WriteAllText:
File.WriteAllText("path to text file", myTextBox.Text);
Then use Process.Start to open it in notepad:
Process.Start("path to notepad.exe", "path to text file");
For non ASCII user.
[DllImport("User32.dll", EntryPoint = "SendMessage", CharSet = CharSet.Unicode)]
private static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
Based on #Peter Mortensen answer
Add CharSet = CharSet.Unicode to the attribute for supporting Unicode characters
I was using the NotepadHelper solution until I discovered it doesn't work on Windows 11. Writing the file to disk and starting with the default text editor seems to be the best solution. This has already been posted, but I discovered you need to pass UseShellExecute=true.
System.IO.File.WriteAllText(path, value);
System.Diagnostics.ProcessStartInfo psi = new() { FileName = path, UseShellExecute = true };
System.Diagnostics.Process.Start(psi);
I write to the System.IO.Path.GetTempPath() folder and run a cleanup when the application exits - searching for a unique prefix pattern for file names used by my app. Something like this:
string pattern = TempFilePrefix + "*.txt";
foreach (string f in Directory.EnumerateFiles(Path.GetTempPath(), pattern))
{
File.Delete(f);
}
I read a list of SIDs from the registry, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList.
How would one resolve the display username (e.g. DOMAIN\user, BUILT-IN\user) given the SID string in C#?
Just found it on the pinvoke.net.
Alternative Managed API:
Available in .Net 2.0:
using System.Security.Principal;
// convert the user sid to a domain\name
string account = new SecurityIdentifier(stringSid).Translate(typeof(NTAccount)).ToString();
The Win32 API function LookupAccountSid() is used to find the name that corresponds to a SID.
LookupAccountSid() has the following signature:
BOOL LookupAccountSid(LPCTSTR lpSystemName, PSID Sid,LPTSTR Name, LPDWORD cbName,
LPTSTR ReferencedDomainName, LPDWORD cbReferencedDomainName,
PSID_NAME_USE peUse);
MSDN Ref.
Here's the P/Invoke reference (with sample code): http://www.pinvoke.net/default.aspx/advapi32.LookupAccountSid
[DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError = true)]
static extern bool LookupAccountSid (
string lpSystemName,
[MarshalAs(UnmanagedType.LPArray)] byte[] Sid,
StringBuilder lpName,
ref uint cchName,
StringBuilder ReferencedDomainName,
ref uint cchReferencedDomainName,
out SID_NAME_USE peUse);