Solved

Unable to connect to COM Component in Windows 7 Pro 64, running VB6 exe program

Posted on 2014-04-30
8
819 Views
Last Modified: 2014-05-02
I am trying to run a very useful utility I wrote myself in Visual Basic 6 many years ago
with a Windows 7 Pro 64-bit installation.

Under Windows XP first you start the PowerPCB  executable, then upon loading the main form the VB6 program 'MainBoard_Client.exe' connects to the PADS COM Type Library, which  accessible to other programs while PowerPCB is running.

PADS COM Type Library is included in the main executable file 'powerpcb.exe'. See visual basic reference to the library, with the VB6 IDE under Windows XP, from VB6 IDE:

COM reference from VB6 IDE
It is also visible in the Microsoft ComView utility as a registered component,   under Windows XP, and the program fully communicates with the COM server, of course:

OLEView running under Windows XP
Now, I only want to transfer and run this program under Windows 7 Pro 64-bit, and to be able to run a VB6 program at all, I had to copy 3 required ocx files to  c:\Windows\SysWOW64\ and executed the following to register components commands under Windows 7 Pro 64:

regsvr32 c:\Windows\SysWOW64\comdlg32.ocx
regsvr32 c:\windows\SysWOW64\MSCOMCT2.OCX
regsvr32 c:\windows\SysWOW64\mscomct2.ocx

Which worked fine, got the dialog that registration of components was successful.

I can also verify, using ComView that the COM Server for PowerPCB was successfully
installed in Windows 7:

Windows 7: PADS type library installed
BUT!  The 2 programs still will not connect with COM.

What else is missing here under Windows 7?

This is the simple form load procedure in the VB6 program that is supposed to connect to the COM server:

Private Sub Form_Load()

Dim view As Object

' extablish connection of client with PCB

On Error GoTo NoPCBStarted

 ' Connect to a running instance of PowerPCB server
    Set powerPCBApp = GetObject(, "PowerPCB.Application")
    Set powerPCBDoc = powerPCBApp.ActiveDocument

If CheckPCBVersion() = False Then
MsgBox "This software requires 'PADS Layout v. 5.3' or later. Some functions may not work with your currently loaded version of " & _
powerPCBApp.Version, vbInformation
End If

'zoom to full board view
Set view = powerPCBDoc.ActiveView
view.SetExtentsToBoard
Set view = Nothing

' clear all selections in PCB
powerPCBDoc.SelectObjects ppcbObjectTypeAll, "*", False

' bring up client as the active application in
' normal state on the desktop
AppActivate "MainBoard_Client"
Me.WindowState = vbNormal

Exit Sub

NoPCBStarted:

MsgBox "Unable to connect to PowerPCB", vbCritical

End

End Sub

Open in new window


And if this procedure starts, with PowerPCB.exe already running, I will just get me to
the exceptions part of the program immediately:

"Unable to connect to PowerPCB"

What is happening here? Is there another missing component under Windows 7?
0
Comment
Question by:AttilaB
  • 5
  • 3
8 Comments
 
LVL 15

Expert Comment

by:eemit
ID: 40032611
- You may need explicitly call the 32-bit version of regsrv32 located in %systemroot%\SysWoW64\regsvr32.exe
- Open up the command prompt with "run as administrator"
0
 

Author Comment

by:AttilaB
ID: 40032730
Are you saying that comdlg32.ocx, MSCOMCT2.OCX, and mscomct2.ocx were not properly registered, even though I was using command prompt with "run as administrator"?

( I searched for 'cm.exe' and started it with Ctrl + Shift + Enter and got all 3 components
to register as seen below:)
Proper Registration of OCX
Also, please note that the VB6 program is running properly under Windows 7, other than not connecting to the COM server in 'powerpcb.exe': It gives me the proper dialog
box I am expecting if unable to connect to COM server. Without these 3 OCXs it would not run at all.

Perhaps something else is missing?
0
 

Author Comment

by:AttilaB
ID: 40032761
OK I will try to re-register these 3 OCXs, using the 32-bit version of regsrv32,
as you are saying shortly, and I will let you know.
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:AttilaB
ID: 40033738
Using the 32-bit version of regsrv32, getting identical results:

Re-registering all three OCXs
I am not pasting the other 2 here, they were giving identical results.

Same result: (Program starts, does not connect to COM server, brings up the dialog box for no connection:

Unable to Connect
0
 
LVL 15

Expert Comment

by:eemit
ID: 40034237
Can you post Err.Number and Err.Description?
0
 

Author Comment

by:AttilaB
ID: 40034615
Thank you. Excellent idea, it is a different error: I made the following change to the code, compiled into EXE and transferred over to the Windows 7 64 OS.

NoPCBStarted:

MsgBox "Unable to connect - Error No: " & Err.Number & "  Desc.: " & Err.Description, vbCritical

End

Open in new window


It turns out, that if the COM server is NOT running regardless of OS (XP or Win7 64) it will give you the same message, as follows here:
Server Running: Both XP and Win 7 64-bit
BUT! On Win7 64, if the server is running, and cannot connect, I get this message:
Error 13, type mismatch.  This is my problem:

Server Running Win 7: Type Mismatch
0
 
LVL 15

Accepted Solution

by:
eemit earned 500 total points
ID: 40034966
Can you find which line of code caused the error?
Have you tried to start powerpcb.exe with "run as administrator"?
0
 

Author Closing Comment

by:AttilaB
ID: 40038204
Yes, I did find which line was causing the error:

 ' Connect to a running instance of PowerPCB server
    Set powerPCBApp = GetObject(, "PowerPCB.Application")

The server was passing down wrong data type to the VB6 client, NOT
the PowerPCB.Application object.

BUT! After I ran powerpcb.exe with as administrator, as you suggested, even though it DID NOT CONNECT TO CLIENT WITH SERVER RUNNING AS ADMINISTRATOR, afterwards, after I RE-STARTED SERVER it just connected fine to the COM client. Every time. And even
after multiple re-starts of the computer.

What is this? Some kind of security issue with Windows 7 Pro 64-bit, perhaps?

I will try the same thing on another Win 7 Pro 64-bit machine.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

On some Windows 7 (SP1) computers, Windows Update becomes super slow even the computer is reasonably fast.  There's one solution that seemed to have worked well for me (after trying a few other suggested solutions).
On Beyond Tools A conversation I recently had with the DevOps manager of a major online retailer really made me think about DevOps monitoring tools (https://www.onpage.com/devops-incident-management-tool/). The manager and I discussed how sever…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question