string startUpFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + "MyexeName.exe";
if (System.IO.File.Exists(startUpFolderPath))
{
return;
}
WshShellClass wshShell = new WshShellClass();
IWshRuntimeLibrary.IWshShortcut shortcut;
shortcut = (IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(startUpFolderPath);
shortcut.TargetPath = Application.ExecutablePath;
shortcut.WorkingDirectory = Application.StartupPath;
shortcut.Save()
C# kaynak kodları ile projelerinize yardımcı açık source code örnekleri bulun.Programlama ile uraşan coderlara yardımcı olur.
30 Kasım 2015 Pazartesi
c# kısayol oluşturma
28 Kasım 2015 Cumartesi
c# proxy arkasındaki ip
public static string GetUserIP() { var ip = ( HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null && HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != "" ) ? HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] : HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; if (ip.Contains( "," )) ip = ip.Split( ',' ).First().Trim(); return ip;}c# zip ve dosya çıkarma
using System;
using System.IO;
using System.IO.Compression;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
string startPath = @"c:\example\start";
string zipPath = @"c:\example\result.zip";
string extractPath = @"c:\example\extract";
ZipFile.CreateFromDirectory(startPath, zipPath, CompressionLevel.Fastest, true);
ZipFile.ExtractToDirectory(zipPath, extractPath);
}
}
}
c# başka bir exeyi yönetici olarak çalıştırma
ProcessStartInfo info = new ProcessStartInfo("Process.exe");
info.UseShellExecute = true;
info.Verb = "runas";
Process.Start(info);
c# yönetici olarak çalıştırılmış mı kontrolu
WindowsPrincipal principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());bool administrativeMode = principal.IsInRole(WindowsBuiltInRole.Administrator);if (!administrativeMode) { ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.Verb = "runas"; startInfo.FileName = Assembly.GetExecutingAssembly().CodeBase; try { Process.Start(startInfo); Application.Exit(); } catch { //User denied access return; } return;}27 Kasım 2015 Cuma
Uac kapatma c#
I try to change my own program setting in registry, and it works well under Vista, Win 7 (UAC enabled). It just has error when running under Win8 (UAC enabled).
Thank you for your suggestion, I'll take a look at serialization.
Additional, this is my code
Thank you for your suggestion, I'll take a look at serialization.
Additional, this is my code
1 | RegistrySecurity rs = new RegistrySecurity(); |
2 | RegistryKey rk = Registry.ClassesRoot.OpenSubKey(subkey, RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.FullControl); // Opens the key again with full control. |
3 | rs.SetOwner(new NTAccount("newAdmin"));// Set the securitys owner to newAdmin |
4 | rs.SetAccessRuleProtection(true, false); |
5 | rk.SetAccessControl(rs);// Set the key with the changed permission so Administrator is now owner. |
Kaydol:
Yorumlar (Atom)