namespace LSFileClient { using Microsoft.Win32; using System; using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; using LSServerService; internal class ClientManager { public static void init(string[] args) { // new string serverIP = ""; string dBName = ""; string isInternet = "0"; string IsConsumer = "0"; //MessageBox.Show("1---------------"+args[0].ToString()); //string inputString = args[0].Replace("^^", " "); //paramsCount=9|userId=1|type=2|left=100|top=100|width=800|height=500|directoryId=113154|fileIds=96892|mainHandle=4918422| //paramsCount=2|downloadPath=F:\lserp\mobile_webls\fileRoot\PDM图纸档案_#2/GCFK21050009_#113154/001_微信图片_20210504203115.jpg|mainHandle=4918422| string inputString = @"paramsCount=4|classType=deleteFile|userId=1|mainHandle=2300632|fileIds=10446"; LSParamsFormatter.bParseResult = LSParamsFormatter.parseParams(inputString); if (!LSParamsFormatter.bParseResult) { MessageBox.Show("参数错误\r\n" + args[0].ToString()); } else { RegistryKey key2 = Registry.CurrentUser.OpenSubKey("AA_ls_Erp V2.0"); if (key2 != null) { RegistryKey key3 = key2.OpenSubKey("File"); if (key3 != null) { dBName = key3.GetValue("datastr", "").ToString(); serverIP = key3.GetValue("ServerName", "").ToString(); isInternet = key3.GetValue("Internet", "1").ToString(); IsConsumer = key3.GetValue("IsConsumer", "1").ToString(); //if (serverIP != "") //{ // serverIP = serverIP.Split(new char[] { '\\', '/' })[0]; //} } } if ((serverIP == "") || (dBName == "")) { MessageBox.Show("连接服务器参数无效,请联系管理员."); } else { if (((LSParamsFormatter.commonModel == 9) || (LSParamsFormatter.commonModel == 11)) || (LSParamsFormatter.commonModel == 3) || (LSParamsFormatter.commonModel == 4) || LSParamsFormatter.commonModel == 12) { LSGlobleVariable.userId = (uint)LSParamsFormatter.userId; } LSClientMain main = new LSClientMain(); main.ProgramEntry(serverIP, dBName, isInternet, IsConsumer); int num = 0; while (num < 6) { if (main.checkSocketState()) { break; } num++; Thread.Sleep(300); } if (num >= 6) { MessageBox.Show("连接服务器失败,请联系管理员."); SendMessage(LSParamsFormatter.mainHandle, 1305, IntPtr.Zero, IntPtr.Zero); } else if ((LSParamsFormatter.commonModel == 9) || (LSParamsFormatter.commonModel == 11) || (LSParamsFormatter.commonModel == 12)) { Application.Run(new FrmBatchProgress(main, serverIP, dBName, IsConsumer)); } else if (LSParamsFormatter.commonModel == 2) { Application.Run(new frmSingleDownload(main, serverIP, dBName, IsConsumer)); } else if (LSParamsFormatter.commonModel == 3) { Application.Run(new frmSmartClient(main, serverIP, dBName, IsConsumer)); } else if (LSParamsFormatter.commonModel == 4) { Application.Run(new frmDelete(main, serverIP, dBName, IsConsumer)); } } } } [DllImport("user32.dll")] protected static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); } }