?
Solved

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

Posted on 2014-04-30
8
Medium Priority
?
837 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 1500 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

How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

Question has a verified solution.

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

When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
Suggested Courses
Course of the Month14 days, 11 hours left to enroll

771 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