public void Release() { if (ppf != null) { Marshal.FinalReleaseComObject(ppf); ppf = null; } if (psl != null) { Marshal.FinalReleaseComObject(psl); psl = null; } }
public void Save(string pszFileName) { // Get a pointer to the IPersistFile interface. ppf = (IPersistFile) psl; ppf.Save(pszFileName, true); }
/// <summary> /// Saves the shortcut to disk. /// </summary> public void Save() { IPersistFile pf = (IPersistFile) m_Link; pf.Save( m_sPath, true ); }
public void Load(string pszFileName) { // Get a pointer to the IPersistFile interface. ppf = (IPersistFile) psl; ppf.Load(pszFileName, 0); psl.Resolve(IntPtr.Zero, 0); }
public void Save(string pszFileName) { // Get a pointer to the IPersistFile interface. ppf = (IPersistFile)psl; ppf.Save(pszFileName, true); }
public void Save() { IPersistFile persistFile = (IPersistFile)m_Link; persistFile.Save(m_sPath, fRemember: true); }
static void Main(string[] args) { if (!File.Exists("watchdog.ini")) { File.WriteAllText("watchdog.ini", "[Watch]\nport=80"); } FileIniDataParser parser = new FileIniDataParser(); var data = parser.ReadFile("watchdog.ini"); var port = Convert.ToInt32(data["Watch"]["port"]); if (args.Length > 0) { if (args[0].Contains("--D")) { Debug = true; } else if (args[0] == "--EnableUpdate" && IsAdministrator()) { ProcessStartInfo startUpd = new ProcessStartInfo { FileName = "cmd.exe", Arguments = "/c sc config wuauserv start=auto", CreateNoWindow = true, UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden, RedirectStandardOutput = true }; Process.Start(startUpd); startUpd.Arguments = "/c net start wuauserv"; Process.Start(startUpd); Environment.Exit(0); } } try { if (Process.GetProcessesByName("Xampp.Watchdog").Length > 1) { Environment.Exit(0); } foreach (var proc in Process.GetProcessesByName("httpd")) { proc.Kill(); } foreach (var proc in Process.GetProcessesByName("mysqld")) { proc.Kill(); } ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; _handler += new EventHandler(Handler); SetConsoleCtrlHandler(_handler, true); if (!Debug) { string StartUp = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), "xampp.watchdog.lnk"); if (!File.Exists(StartUp)) { IShellLink link = (IShellLink) new ShellLink(); link.SetDescription("Auto restart xampp, written by PoH98"); link.SetPath(Path.Combine(Environment.CurrentDirectory, "xampp.watchdog.exe")); link.SetWorkingDirectory(Environment.CurrentDirectory); IPersistFile file = (IPersistFile)link; file.Save(StartUp, false); } } apache = Process.Start(apache_start); apache.EnableRaisingEvents = true; mysql = Process.Start(mysql_start); mysql.EnableRaisingEvents = true; apache.Exited += Apache_Exited; mysql.Exited += Mysql_Exited; Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("[" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "]: Apache started with id " + apache.Id); Console.WriteLine("[" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "]: MySQL started with id " + mysql.Id); DateTime LastBackUp = DateTime.MinValue; string ip; do { using (WebClient webclient = new WebClient()) { ip = webclient.DownloadString("http://bot.whatismyipaddress.com/"); } Console.ResetColor(); Console.WriteLine("[" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "]: IP Address detected as " + ip); CheckWindowsUpdate(); try { if (!IsPortOpen(ip, port, new TimeSpan(0, 0, 5))) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("[" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "]:Server check ERROR on address " + ip + ":" + port + "!"); KillAll(false); apache = Process.Start(apache_start); apache.EnableRaisingEvents = true; mysql = Process.Start(mysql_start); mysql.EnableRaisingEvents = true; apache.Exited += Apache_Exited; mysql.Exited += Mysql_Exited; Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("[" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "]: Apache started with id " + apache.Id); Console.WriteLine("[" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "]: MySQL started with id " + mysql.Id); Thread.Sleep(30000); } else { Thread.Sleep(30000); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("[" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "]:Server check SUCCESS on address " + ip + ":" + port + "!"); } } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message); } if (!Debug) { if (LastBackUp.Date != DateTime.Now.Date && DateTime.Now.Hour == 0) { KillAll(false); BackUp(Path.Combine(Environment.CurrentDirectory, "mysql\\data")); foreach (var folder in Directory.GetDirectories(Path.Combine(Environment.CurrentDirectory, "mysql\\data"))) { BackUp(folder); } LastBackUp = DateTime.Now.Date; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("[" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "]:Database Backup success! Written " + SizeSuffix(byteswritten) + " total! "); byteswritten = 0; apache = Process.Start(apache_start); mysql = Process.Start(mysql_start); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("[" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "]: Apache started with id " + apache.Id); Console.WriteLine("[" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "]: MySQL started with id " + mysql.Id); } } }while (true); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.ToString()); Console.ReadLine(); } }
public string GetText(string discoveryPath) // path is the path of the .doc, .xls or .ppt file // text is the variable in which all the extracted text will be stored { String result = ""; int count = 0; IFilter ifilt = (IFilter)(new CFilter()); try { //System.Runtime.InteropServices.UCOMIPersistFile ipf = (System.Runtime.InteropServices.UCOMIPersistFile)(ifilt); IPersistFile ipf = (IPersistFile)(ifilt); ipf.Load(discoveryPath, 0); uint i = 0; STAT_CHUNK ps = new STAT_CHUNK(); ifilt.Init(IFILTER_INIT.NONE, 0, null, ref i); int hr = 0; while (hr == 0) { ifilt.GetChunk(out ps); if (ps.flags == CHUNKSTATE.CHUNK_TEXT) { uint pcwcBuffer = 1000; int hr2 = 0; while (hr2 == Constants.FILTER_S_LAST_TEXT || hr2 == 0) { try { pcwcBuffer = 1000; StringBuilder sbBuffer = new StringBuilder((int)pcwcBuffer); hr2 = ifilt.GetText(ref pcwcBuffer, sbBuffer); // Console.WriteLine(pcwcBuffer.ToString()); if (hr2 >= 0) { result += sbBuffer.ToString(0, (int)pcwcBuffer); } //textBox1.Text +="\n"; // result += "#########################################"; count++; } catch (COMException myE) { Console.WriteLine(myE.Data + "\n" + myE.Message + "\n"); } } } } } catch (COMException myE) { Console.WriteLine(myE.Data + "\n" + myE.Message + "\n"); } finally { Marshal.ReleaseComObject(ifilt); } return(result); }
/// <summary> /// Saves the shortcut to disk. /// </summary> internal void Save() { IPersistFile pf = (IPersistFile)m_Link; pf.Save(m_sPath, true); }
public void save(string fileName) { IPersistFile entity = (IPersistFile)shellLink; entity.Save(fileName, true); }
static void Main(string[] args) { if (args.Length == 2 && args[0] == "/get") { var fp = args[1]; IShellLinkW plnk = (IShellLinkW) new CShellLink(); IPersistFile ppf = (IPersistFile)plnk; ppf.Load(fp, STGM_READ); // http://8thway.blogspot.jp/2012/11/csharp-appusermodelid.html IPropertyStore pps = (IPropertyStore)plnk; PropVariant v = new PropVariant(); pps.GetValue(ref AppUserModelIDKey, ref v); String s = ""; if (v.vt == VT_BSTR) { s = Marshal.PtrToStringUni(v.pVal); } if (v.vt == VT_LPWSTR) { s = Marshal.PtrToStringUni(v.pVal); } Console.WriteLine(s); } else if (args.Length == 2 && args[0] == "/list") { var fp = args[1]; IShellLinkW plnk = (IShellLinkW) new CShellLink(); IPersistFile ppf = (IPersistFile)plnk; ppf.Load(fp, STGM_READ); IPropertyStore pps = (IPropertyStore)plnk; uint cx; pps.GetCount(out cx); for (uint x = 0; x < cx; x++) { PropertyKey k = new PropertyKey(); pps.GetAt(x, ref k); PropVariant v = new PropVariant(); pps.GetValue(ref k, ref v); String s = ""; if (v.vt == VT_BSTR) { s = Marshal.PtrToStringUni(v.pVal); } if (v.vt == VT_LPWSTR) { s = Marshal.PtrToStringUni(v.pVal); } Console.WriteLine(k.fmtid.ToString("B") + " " + k.pid + " " + v.vt + " " + s); } } else if (args.Length == 3 && args[0] == "/set") { var fp = args[1]; var s = args[2]; IShellLinkW plnk = (IShellLinkW) new CShellLink(); IPersistFile ppf = (IPersistFile)plnk; ppf.Load(fp, STGM_READWRITE); // http://8thway.blogspot.jp/2012/11/csharp-appusermodelid.html IPropertyStore pps = (IPropertyStore)plnk; PropVariant pv = new PropVariant { vt = VT_LPWSTR, pVal = Marshal.StringToBSTR(s) }; pps.SetValue(ref AppUserModelIDKey, ref pv); pps.Commit(); ppf.Save(fp, false); } else { helpYa(); } }