public string GetAppCode() { LoginRequest request = new LoginRequest(); if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["appkey"])) { request.client_id = ConfigurationManager.AppSettings["appkey"]; } else { throw new Exception("没有配置appkey!"); } request.state = "ok"; string url = request.GetUrl(); string querystring = SDKFactory.Executor.GetDataString(request); string fullurl = url.TrimEnd('?') + "?" + querystring; TransferTokenRequest tokenrequest = new TransferTokenRequest(); var handle = Process.GetCurrentProcess().MainWindowHandle; Form parent = Form.FromHandle(handle) as Form; frmLogin form = new frmLogin(fullurl, tokenrequest); FormWebHandler handler = new FormWebHandler(form.webBrowser1, form); form.ShowDialog(parent); return tokenrequest.code; }