Private Const GW_HWNDNEXT = 2Private Declare Function GetwindowThreadProcessID lib "user32" (ByVal hwnd As Long,lpDWProcessID As Long) As LongPrivate Declare Function GetParent lib "user32" (ByVal hwnd As Long) As LongPrivate Declare Function FinDWindow lib "user32" Alias "FinDWindowA" (ByVal lpClassname As Long,ByVal lpWindowname As Long) As LongPrivate Declare Function Getwindow lib "user32" (ByVal hwnd As Long,ByVal wCmd As Long) As LongPrivate Declare Function GetwindowText lib "user32" Alias "GetwindowTextA" (ByVal hwnd As Long,ByVal lpString As String,ByVal cch As Long) As LongPrivate Declare Function SetParent lib "user32" (ByVal hWndChild As Long,ByVal hWndNewParent As Long) As LongFunction InstancetoWnd(ByVal target_pID As Long) As LongDim test_hwnd As LongDim test_pID As LongDim test_thread_ID As Longtest_hwnd = FinDWindow(ByVal 0&,ByVal 0&)do while test_hwndIf GetParent(test_hwnd) = 0 Thentest_thread_ID = GetwindowThreadProcessID(test_hwnd,test_pID)If test_pID = target_pID ThenInstancetoWnd = test_hwndExit DoEnd IfEnd Iftest_hwnd = Getwindow(test_hwnd,GW_HWNDNEXT)LoopEnd FunctionPrivate Sub Form_Load()Dim pID As LongpID = Shell("calc.exe",vbnormalFocus) '这里可修改程序路径If pID = 0 ThenExit SubEnd IfCalc_Hwnd& = InstancetoWnd(pID)Calc_oldParent& = SetParent(Calc_Hwnd&,Me.hwnd)End Sub总结
以上是内存溢出为你收集整理的VB 让别的程序在自己窗体中运行全部内容,希望文章能够帮你解决VB 让别的程序在自己窗体中运行所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)