|
@@ -261,45 +261,56 @@ namespace PDF_Master
|
|
|
if (pros.Length > 1)
|
|
|
{
|
|
|
if (e != null && e.Args != null && e.Args.Length > 0)
|
|
|
- {
|
|
|
- foreach (var filePath in e.Args)
|
|
|
- {
|
|
|
- if (filePath.ToLower().Contains(".pdf") && Path.GetExtension(filePath).ToLower() == ".pdf")
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- uint mapSize = 1024;
|
|
|
- IntPtr mapHandle = Win32Helper.CreateFileMapping(IntPtr.Zero, IntPtr.Zero, Win32Helper.FileMapProtection.PageReadWrite, 0, mapSize, "Global\\sharePathNotify");
|
|
|
-
|
|
|
- if (mapHandle != IntPtr.Zero)
|
|
|
- {
|
|
|
- IntPtr writePtr = Win32Helper.MapViewOfFileEx(mapHandle, Win32Helper.FileMapAccessType.Read | Win32Helper.FileMapAccessType.Write, 0, 0, UIntPtr.Zero, IntPtr.Zero);
|
|
|
- Marshal.Copy(filePath.ToCharArray(), 0, writePtr, filePath.Length);
|
|
|
- MD5 currMd5 = MD5.Create();
|
|
|
- byte[] hashArray = currMd5.ComputeHash(Encoding.Default.GetBytes(filePath));
|
|
|
- StringBuilder hexBuilder = new StringBuilder();
|
|
|
- foreach (byte code in hashArray)
|
|
|
- {
|
|
|
- hexBuilder.AppendFormat("{0:X2}", code);
|
|
|
- }
|
|
|
-
|
|
|
- IntPtr waitPtr = Win32Helper.CreateEvent(IntPtr.Zero, true, false, "Global\\shareWaitNotify" + hexBuilder.ToString());
|
|
|
- if (waitPtr != IntPtr.Zero)
|
|
|
- {
|
|
|
- Win32Helper.PostMessage((IntPtr)0xffff, MsgId, IntPtr.Zero, (IntPtr)filePath.Length);
|
|
|
- Win32Helper.WaitForSingleObject(waitPtr, 5000);
|
|
|
- Win32Helper.CloseHandle(waitPtr);
|
|
|
- }
|
|
|
- Win32Helper.UnmapViewOfFile(writePtr);
|
|
|
- Win32Helper.CloseHandle(mapHandle);
|
|
|
- }
|
|
|
- }
|
|
|
- catch
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
+ {
|
|
|
+ if(Webgoapp(e.Args)==true)
|
|
|
+ {
|
|
|
+ Win32Helper.PostMessage((IntPtr)0xffff, WakeId, IntPtr.Zero, IntPtr.Zero);
|
|
|
+ IntPtr waitPtr = Win32Helper.CreateEvent(IntPtr.Zero, true, false, "Global\\shareWaitNotify" + Guid.NewGuid());
|
|
|
+ Win32Helper.WaitForSingleObject(waitPtr, 5000);
|
|
|
+ Win32Helper.CloseHandle(waitPtr);
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ foreach (var filePath in e.Args)
|
|
|
+ {
|
|
|
+ if (filePath.ToLower().Contains(".pdf") && Path.GetExtension(filePath).ToLower() == ".pdf")
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ uint mapSize = 1024;
|
|
|
+ IntPtr mapHandle = Win32Helper.CreateFileMapping(IntPtr.Zero, IntPtr.Zero, Win32Helper.FileMapProtection.PageReadWrite, 0, mapSize, "Global\\sharePathNotify");
|
|
|
+
|
|
|
+ if (mapHandle != IntPtr.Zero)
|
|
|
+ {
|
|
|
+ IntPtr writePtr = Win32Helper.MapViewOfFileEx(mapHandle, Win32Helper.FileMapAccessType.Read | Win32Helper.FileMapAccessType.Write, 0, 0, UIntPtr.Zero, IntPtr.Zero);
|
|
|
+ Marshal.Copy(filePath.ToCharArray(), 0, writePtr, filePath.Length);
|
|
|
+ MD5 currMd5 = MD5.Create();
|
|
|
+ byte[] hashArray = currMd5.ComputeHash(Encoding.Default.GetBytes(filePath));
|
|
|
+ StringBuilder hexBuilder = new StringBuilder();
|
|
|
+ foreach (byte code in hashArray)
|
|
|
+ {
|
|
|
+ hexBuilder.AppendFormat("{0:X2}", code);
|
|
|
+ }
|
|
|
+
|
|
|
+ IntPtr waitPtr = Win32Helper.CreateEvent(IntPtr.Zero, true, false, "Global\\shareWaitNotify" + hexBuilder.ToString());
|
|
|
+ if (waitPtr != IntPtr.Zero)
|
|
|
+ {
|
|
|
+ Win32Helper.PostMessage((IntPtr)0xffff, MsgId, IntPtr.Zero, (IntPtr)filePath.Length);
|
|
|
+ Win32Helper.WaitForSingleObject(waitPtr, 5000);
|
|
|
+ Win32Helper.CloseHandle(waitPtr);
|
|
|
+ }
|
|
|
+ Win32Helper.UnmapViewOfFile(writePtr);
|
|
|
+ Win32Helper.CloseHandle(mapHandle);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -411,9 +422,37 @@ namespace PDF_Master
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- base.OnStartup(e);
|
|
|
- }
|
|
|
+ base.OnStartup(e);
|
|
|
+ Webgoapp(e.Args);
|
|
|
|
|
|
+ }
|
|
|
+ public static bool Webgoapp(string[] args)
|
|
|
+ {
|
|
|
+ bool flg = false;
|
|
|
+ if (args.Length > 0)
|
|
|
+ {
|
|
|
+ string url = args[0];
|
|
|
+ MessageBox.Show(url);
|
|
|
+ string[] urlParts = url.Split(new char[] { '?', '&' });
|
|
|
+ Dictionary<string, string> parameters = new Dictionary<string, string>();
|
|
|
+
|
|
|
+ foreach (string part in urlParts.Skip(1))
|
|
|
+ {
|
|
|
+ string[] keyValue = part.Split('=');
|
|
|
+ if (keyValue.Length == 2)
|
|
|
+ {
|
|
|
+ flg = true;
|
|
|
+ string key = keyValue[0];
|
|
|
+ string value = Uri.UnescapeDataString(keyValue[1]); // 对参数值进行URL解码
|
|
|
+ MessageBox.Show(key +":"+ value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ return flg;
|
|
|
+ }
|
|
|
|
|
|
private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
|
|
|
{
|