我使用的示例代碼創建在VB.Net的ActiveX - 埃克COM服務器:外的PROC埃克服務器
http://code.msdn.microsoft.com/windowsapps/VBExeCOMServer-74ecdb1c
當我打電話GetCurrentProcessID從Active-X-內Exe,它會返回與調用應用程序相同的ID。
有人可以告訴我,如果這是很自然的,或者我是否在封裝ActiveX-Exe組件時做了錯誤?
我這樣的測試它:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
_MouseIndicator = New twsMouseIndicator.clsMouseIndicator
With _MouseIndicator
.ImagePath = "d:\dev\projects\osc\gui\autoclick\prog4.png"
.Size = 300
.Alpha = 155
.FollowMouse = True
.Active = True
End With
Dim iProcessIDOutOfProcID As Integer = _MouseIndicator.CurrentProcessID
Dim iCallerProcessID As Integer = GetCurrentProcessId()
If iProcessIDOutOfProcID = iCallerProcessID Then
MessageBox.Show("ProcIDs are the same, namely " & iCallerProcessID & ". This can not be right!")
Else
MessageBox.Show("Everything is okay.")
End If
End Sub
在調用應用程序 「GetCurrentProcessID」 被聲明爲
Module Module1
''' <summary>
''' Get current process ID.
''' </summary>
''' <returns></returns>
<DllImport("kernel32.dll")> _
Public Function GetCurrentProcessId() As UInt32
End Function
End Module
在亂PROC-COM-服務器,現宣佈像這樣:
Public Function CurrentProcessID() As UInt32
Return NativeMethod.GetCurrentProcessId
End Function
Friend Class NativeMethod
''' <summary>
''' Get current process ID.
''' </summary>
''' <returns></returns>
<DllImport("kernel32.dll")> _
Friend Shared Function GetCurrentProcessId() As UInt32
End Function
你調用'GetCurrentProcessID'而不是'GetCurrentProcess'? – 2014-09-22 23:15:12
@ 500-InternalServerError是。朋友共享函數GetCurrentProcessId()作爲UInt32 – tmighty 2014-09-23 06:54:44
您可能需要顯示您添加的代碼以顯示進程ID以及如何比較它們,因爲它*適用於我的系統* http://i.imgur.com/5fO51vz.png – Plutonix 2014-09-25 02:13:05