1

I'm using this code:

Private Function CreateProcesByGuid(ByVal guid As String) As Object
    Return DirectCast(Activator.CreateInstance(Type.GetTypeFromCLSID(New Guid(guid))), Object)
End Function

To run COM process using its GUID. Now I need to get guid of active process. Is there any way to do that? I have try this:

Dim g As GuidAttribute = GuidAttribute.GetCustomAttribute(p.GetType().Assembly, GetType(GuidAttribute))

If Not g Is Nothing Then
    MsgBox(g.Value)
End If

But it doesnt work :(

My code:

        Dim p As Process

        For Each p In ps

            Try
                Dim g As GuidAttribute = GuidAttribute.GetCustomAttribute(p.GetType().Assembly, GetType(GuidAttribute))

                MsgBox(g.Value)

            Catch

            End Try

        Next p

Is there other way to get GUID from active process? I need to check if some process is working and if it is then to check his GUID.

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
miQ
  • 21
  • 1
  • 7
  • What do you want to do exactly, call an external COM? – Gabriel Sep 09 '15 at 23:13
  • I have my VB.NET application that connect to Corel Draw using COM. I'm able to run different Corel version (if there is more then one installed) by changing reference on startup. That works fine i most cases. Now I want to go forward and try something else. I want to check If there is a CorelDrw process running and check what version of it is currently running. I can do this by checking version of file or by GUID. First function from my post allow to create CorelDraw.Application by inputed GUID. Is there a way to get GUID or path of process (exe file path)? – miQ Sep 10 '15 at 08:09
  • The attribute CLSID is an attribute of a class, not a process. – Gabriel Sep 10 '15 at 16:54
  • With WMI you could find the Corel Draw process "ExecutablePath", then you could use reflection to get the version of the exe : Assembly.LoadFrom(executablePath).GetName().Version – Gabriel Sep 10 '15 at 17:01
  • Yes and that's the way to create COM object :) When I create COM object CorelDraw process is starting and I can show it by setting property visible to true. Im using this code: http://stackoverflow.com/questions/1093536/how-does-the-c-sharp-compiler-detect-com-types – miQ Sep 10 '15 at 17:02

0 Answers0