Solved

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

Posted on 2014-04-30
8
809 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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup". After a while, you have entered a loop for Auto repair which does not fix anything and you will be in a  panic as all your work w…
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…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now