Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

Peter Walburn

@Peter Walburn
About
Posts
4
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Determine User Role (Vista)
    P Peter Walburn

    I managed to do this by adding this class to my application: using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using System.Security.Principal; namespace Gauge { public static class mySecurity { #region Constants const UInt32 TOKEN_QUERY = 8; const int INT_SIZE = 4; #endregion #region Enumerations private enum TOKEN_ELEVATION_TYPE { TokenElevationTypeDefault = 1, TokenElevationTypeFull, TokenElevationTypeLimited } public enum TOKEN_INFO_CLASS { TokenUser = 1, TokenGroups, TokenPrivileges, TokenOwner, TokenPrimaryGroup, TokenDefaultDacl, TokenSource, TokenType, TokenImpersonationLevel, TokenStatistics, TokenRestrictedSids, TokenSessionId, TokenGroupsAndPrivileges, TokenSessionReference, TokenSandBoxInert, TokenAuditPolicy, TokenOrigin, TokenElevationType, TokenLinkedToken, TokenElevation, TokenHasRestrictions, TokenAccessInformation, TokenVirtualizationAllowed, TokenVirtualizationEnabled, TokenIntegrityLevel, TokenUIAccess, TokenMandatoryPolicy, TokenLogonSid, MaxTokenInfoClass // MaxTokenInfoClass should always be the last enum } #endregion #region WIN API FUNCTIONS [DllImport("kernel32.dll")] public static extern IntPtr GetCurrentProcess(); [DllImport("advapi32.dll", SetLastError=true)] public static extern Boolean OpenProcessToken(IntPtr ProcessHandle, UInt32 DesiredAccess, out IntPtr TokenHandle); [DllImport("advapi32.dll", SetLastError=true)] public static extern Boolean GetTokenInformation(IntPtr TokenHandle, TOKEN_INFO_CLASS TokenInformationClass, IntPtr TokenInformation, int TokenInformationLength, out uint ReturnLength); #endregion #region Public Methods /// /// Returns True when the current user is a member of the /// Administrators group and is also running the process /// elevated as an Administrator, otherwise returns false. /// /// /// true if user is running the process elevated as an Administrator; otherwise, false. /// public static Boolean IsRunningAsAdmin(WindowsPrincipal pWindowsPrincipal)

    C# help learning

  • ProcessStartInfo
    P Peter Walburn

    I've found out that it does work after all. I started a batch file that printed the current directory and ran this from the process and it did print the Working Directory!!! I've spent ages trying to get it working with Notepad and kept trying the File/Save As... to see if the folder was the Working Directory. I didn't realise that it was always the last one used. Pete

    C# help csharp

  • ProcessStartInfo
    P Peter Walburn

    I've found out that it does work after all. I started a batch file that printed the current directory and ran this from the process and it did print the Working Directory!!! I've spent ages trying to get it working with Notepad and kept trying the File/Save As... to see if the folder was the Working Directory. I didn't realise that it was always the last one used. Pete

    C# help csharp

  • ProcessStartInfo
    P Peter Walburn

    Hi, I have a C# program that will start another external program (such as notepad). The C# program needs to pass arguments and the working directory to the external program. I have attempted to do this like: Process process = new Process(); try { process.StartInfo.UseShellExecute = false; process.StartInfo.FileName = @"c:\Windows\notepad.exe"; process.StartInfo.Arguments = @"c:\test.txt"; process.StartInfo.WorkingDirectory = @"c:\temp"; process.Start(); process.WaitForExit(); } catch { MessageBox.Show("Error running " + strExe, "Error", MessageBoxButtons.OK); } Notepad does start and opens the correct file, but the Working Directory has not been set. I have tried setting the current directory of the C# applicaiton, then running the notepad process, but the Working Directory is still not set. Please help! Pete

    C# help csharp
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups