在Winform中嵌入exe程序
当前位置:点晴教程→知识管理交流
→『 技术文档交流 』
开发环境:.NET Framework版本:4.8 开发工具:Visual Studio 2022
if (AppProcess != null) { Release(); } try { ProcessStartInfo startInfo = new ProcessStartInfo(appFilename); startInfo.UseShellExecute = true; startInfo.WindowStyle = ProcessWindowStyle.Minimized; AppProcess = Process.Start(startInfo); AppProcess.EnableRaisingEvents = true; AppProcess.WaitForInputIdle(); Embed(AppProcess.MainWindowHandle); } catch { Release(); } return Path.GetFileNameWithoutExtension(appFilename);
public string Embed(string className, string windowName) { try { IntPtr handle = FindWindow(className, windowName); Embed(handle); } catch { } return windowName; }
public string Embed(IntPtr handle) { try { SetParent(handle, this.Handle); SetWindowLong(new HandleRef(this, handle), GWL_STYLE, WS_VISIBLE); MoveWindow(handle, 0, 0, this.Width, this.Height, true); } catch { } StringBuilder title = new StringBuilder(256); GetWindowText(handle, title, title.Capacity); return title.ToString(); }
![]() 转载:https://mp.weixin.qq.com/s/KXyUe-ALW9nb9jKRhkXtCQ 该文章在 2024/1/24 23:23:04 编辑过 |
关键字查询
相关文章
正在查询... |