Question

64-bit code calls 32-bit DLL through ATL COM adapter but gets 64-bit version, not 32-bit

Asked by: EdAtCertFirst

My 64-bit code needs to call 32-bit DLL code that cannot be recompiled in 64-bit (bought DLL, not the source). I wrote an adapter using ATL/COM out of process server. I am using Visual Studio 2008, C++.
My 64-bit client works with the adapter compiled in 64-bit mode and when both are compiled in 32-bit mode, they work. I am looking for the magic function call, parameter, or registry modification to make the 64-to-32-bit combination work. The two articles in MSDN about 64-bit to 32-bit calls do not help.
The adapter is an out of process COM server, an EXE written with ATL.
I have a .zip file of my code but even the .sln file is not allowed in a .zip by exp-xch.

// Client2.cpp				2009-08-06
//
//		Test driver for COM Adapter3 to access the Calculator DLL
//
#include <windows.h>
#include <objbase.h>
#include <iostream>
#include <iomanip>
using namespace std;
 
#include <atlbase.h>
#include <atldef.h>
#include <windef.h>
#include "ComAdapter3_i.h"
 
///////////////////////////// Interface code for accessing the COM Adapter ///////////////////////////////////////
 
int main()
{
	// Initialize COM
 
	HRESULT hr = 0;
	LPUNKNOWN pServer = 0;
	ICoCalc* calc = 0;
 
	::CoInitialize(NULL);
 
// Tried this:
	//PVOID sv = 0;
	//Wow64DisableWow64FsRedirection(&sv);
 
	hr = CoCreateInstance(CLSID_CoCalc, NULL, CLSCTX_LOCAL_SERVER, IID_IUnknown, (LPVOID*) &pServer);
	if (FAILED(hr))
	{
		cout << "Failed to load server\n";
		goto cleanup;
	}
 
	hr = pServer->QueryInterface(IID_ICoCalc, (LPVOID*)&calc);
	if (FAILED(hr))
	{
		cout << "ICalc not found" << endl;
		goto cleanup;
	}
 
	////////////////////////// Normal Application Code //////////////////////////////
 
	cout << "\n\tCalcTest\n\n\n";
 
	long a = 0, b = 0, c = 0;
 
	while (cout << "Enter two integers or Q to quit: ", cin >> a >> b)
	{
		// COM keeps the function addresses in the VTable, makes virtual function calls
		c = calc->Add(a, b);		// a proxy layer could hide calc pointer
		cout << "Sum = " << c << endl;
///  I modified Add to just:   return 8 * sizeof(size_t);
///  It returns 32 or 64 to show what version of code is running in the "COM server"
		cout << "\nClient calc: " << calc << endl;
		cout << "Add: a: " << a << "  &a: " << &a << endl;
		cout << "     b: " << b << "  &b: " << &b << endl;
		cout << "     c: " << c << "  &c: " << &c <<endl;
	}
 
cleanup:		// Cannot build a new ComServer until its usage count is zero.
	if (calc) 
		hr = calc->Release();
	if (pServer)
		hr = pServer->Release();
	CoUninitialize();
	return hr;
}
 
 
 
// CoCalc.cpp : Implementation of CCoCalc
//
//	Test program with local Add function representing code that would be in 32-bit DLL.
//	Calling the DLL will be easy after the 64-32 barrier is fixed.
//
//  When launching Visual Studio, run as Administrator so that various build steps will work.
//  Build ComAdapter3. Then build ComAdapter3PS by right-clicking on that Project name and selecting
//  Project only > Rebuild on ComAdapter3PS.
//
//  Next, go to Client3 directory and run COPY.BAT from a command line window. It copies some generated files.
//  I like keeping the client and server separated.
//  Then build the client3 program and run it.
//  Be careful to check that client is 64-bits and Adapter is 32-bits. Test shows 64-bit Adapter is loaded, matching the
//  bit-ness of the client. I need to turn off the direct matching and access the 32-bit version.
//  The code is basically correct, just missing the magic instructions to override that mapping.
//  Building both Client and Adapter in 32 or 64-bit mode shows correct 32 or 64 output.
 
#include "stdafx.h"
#include "CoCalc.h"
#include <cstddef>
#include <cstdlib>
 
// CCoCalc
 
STDMETHODIMP CCoCalc::Add(LONG a, LONG b)
{
	long c = a + b;
 
	c = sizeof(size_t) * 8;		// report 32-bit or 64-bit version instead of sum to prove the 64 to 32 call works
 
	return c;
}

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-08-09 at 22:30:28ID24639043
Tags

COM

,

ATL

,

64-bit

,

x64

Topics

Microsoft Visual C++

,

Windows ATL / WTL / COM Programming

,

Windows 64-bit

Participating Experts
1
Points
400
Comments
10

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. ATL or VB
    Do components written in ATL/COM work faster than ones written in VB.what are the differences.Ive found that the DLL size is larger for the one written in ATL

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: Gideon7Posted on 2009-08-10 at 05:14:58ID: 25059163

There is no magic call.  The choice of COM process server is determined solely by the registry (HKEY_CURRENT_USER\CLSID and HKEY_LOCAL_MACHINE\CLSID).  You might be running into some confusion because multiple 32-bit and 64-bit proxy server DLLs for the same CLSID might be registered different hives of HKEY_CLASSES_ROOT with registry reflection in coming into play.

Registry reflection occurs on on W2K3 x64, Vista x64 and W2K8 x64.  It copies the LocalServer32 entry between the 64-bit and 32-bit registry hives.  It uses a last-writer-wins policy.  So whichever side (32-bit or 64-bit) last wrote the LocalServer32 value will get reflected into the other hive and 'win'.  See http://msdn.microsoft.com/en-us/library/aa384182.aspx and http://msdn.microsoft.com/en-us/library/aa384182.aspx

To add to the confusion HKEY_CURRENT_USER\CLSID can also be reflected and can override HKLM keys.

(Registry reflection is a confusing hack.  It has been removed  from WIndows 7 x64 and W2K8R2 x64.)

Carefully check HKEY_LOCAL_MACHINE\Software\CLSID\{GUID} and HKEY_LOCAL_MACHINE\Software\Wow6432Node\CLSID\{GUID}.  Verify that the both point to the desired target server path.  Also check under HKEY_CURRENT_USER.  If you are using a custom proxy DLL also check its GUID for InprocServer32 to make sure it is pointing  to the right DLL.

Good luck!

 

by: EdAtCertFirstPosted on 2009-08-10 at 06:33:31ID: 25059741

That sounds good. I will check it out. The "last-writer-wins" policy does not seem to be in effect because I can just recompile the client in 32 or 64-bit mode and it always calls the matching bit-ness version of the COM EXE.

I will make sure there is no 64-bit COM adapter with that name/CLSID/GUID and see what happens.

Thanks!

Ed

 

by: EdAtCertFirstPosted on 2009-08-10 at 21:41:00ID: 25066182

Gideon7:
I cleaned up the registry, renamed the programs, built ComServer32b in 32-bit mode only and Client64 in 64-bit mode. I now get E_NOINTERFACE from the QueryInterface call.

I am building in separate Solutions, copying some generated files from server to client directory and adding the existing files to the project:

copy ..\ComServer32b\ComServer32b_i.c .
copy ..\ComServer32b\ComServer32b_i.h .
copy ..\ComServer32b\Debug\ComServer32b.tlb .
copy ..\ComServer32b\Resource.h .

I could E-mail a zip file of the VS2000 code, if you want it. Are there App Wizard or Class Wizard settings I am doing wrong?

Thanks,

Ed

// Client64b.cpp		2009-08-10
//
//		Test program for ComServer32b
//
// Notes:
//			Run Visual Studio in Administrator mode (right click on icon, choose Run as Administrator).
//			After building companion ComServer32b, run copy.bat script file from command line to pull some files to here.
//			Answer "yes" to messages about reloading files that have been changed outside of VS.
//			Then build and run Client64b. Enter two arbitary integers to test the Add function.
//
#include <windows.h>
#include <objbase.h>
#include <iostream>
#include <iomanip>
using namespace std;
 
#include <atlbase.h>
#include <atldef.h>
#include <windef.h>
#include "ComServer32b_i.h"
	
#include <iostream>
#include <iomanip>
using namespace std;
 
// Interface code for accessing the COM Adapter 
 
int main()
{
	HRESULT hr = 0;
	LPUNKNOWN pServer = 0;
	ICalc* calc = 0;
 
	hr = ::CoInitialize(NULL);
 
	hr = CoGetClassObject(CLSID_Calc, CLSCTX_LOCAL_SERVER, NULL, IID_IClassFactory, (LPVOID*) &pServer);
 
	if (FAILED(hr))
	{
		cout << "Failed to load server\n";
		goto cleanup;
	}
 
	hr = pServer->QueryInterface(IID_ICalc, (LPVOID*)&calc);
	if (FAILED(hr))
	{
		cout << "ICalc not found: " << hex << hr << endl;
		goto cleanup;
	}
 
// Normal Application Code
 
	cout << "\n\tCalcTest\n\n\n";
 
	long a = 0, b = 0, c = 0;
 
	while (cout << "Enter two integers or Q to quit: ", cin >> a >> b)
	{
		// COM keeps the function addresses in the VTable, makes virtual function calls
		hr = calc->Add(a, b, &c);		// a proxy layer could hide calc pointer
		cout << "Sum = " << c << endl;
 
		cout << "\nClient calc: " << calc << endl;
		cout << "Add: a: " << a << "  &a: " << &a << endl;
		cout << "     b: " << b << "  &b: " << &b << endl;
		cout << "     c: " << c << "  &c: " << &c <<endl;
	}
 
cleanup:	// Cannot build a new ComServer until its usage count is zero.
	if (calc) 
		hr = calc->Release();
 
	if (pServer)
		hr = pServer->Release();
 
	CoUninitialize();
 
	return hr;
}
 
 
=============================== ComServer32b =========================
 
// Calc.cpp : Implementation of CCalc
 
#include "stdafx.h"
#include "Calc.h"
 
 
// CCalc
 
 
STDMETHODIMP CCalc::Add(LONG a, LONG b, LONG* c)
{
	*c = a + b;
 
	return S_OK;
}
 
////////////////////////ComServer32b_i.h//////////////////////
 
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
 
 
 /* File created by MIDL compiler version 7.00.0500 */
/* at Tue Aug 11 00:16:39 2009
 */
/* Compiler settings for .\ComServer32b.idl:
    Oicf, W1, Zp8, env=Win32 (32b run)
    protocol : dce , ms_ext, c_ext, robust
    error checks: stub_data 
    VC __declspec() decoration level: 
         __declspec(uuid()), __declspec(selectany), __declspec(novtable)
         DECLSPEC_UUID(), MIDL_INTERFACE()
*/
//@@MIDL_FILE_HEADING(  )
 
#pragma warning( disable: 4049 )  /* more than 64k source lines */
 
 
/* verify that the <rpcndr.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 475
#endif
 
#include "rpc.h"
#include "rpcndr.h"
 
#ifndef __RPCNDR_H_VERSION__
#error this stub requires an updated version of <rpcndr.h>
#endif // __RPCNDR_H_VERSION__
 
#ifndef COM_NO_WINDOWS_H
#include "windows.h"
#include "ole2.h"
#endif /*COM_NO_WINDOWS_H*/
 
#ifndef __ComServer32b_i_h__
#define __ComServer32b_i_h__
 
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
 
/* Forward Declarations */ 
 
#ifndef __ICalc_FWD_DEFINED__
#define __ICalc_FWD_DEFINED__
typedef interface ICalc ICalc;
#endif 	/* __ICalc_FWD_DEFINED__ */
 
 
#ifndef __Calc_FWD_DEFINED__
#define __Calc_FWD_DEFINED__
 
#ifdef __cplusplus
typedef class Calc Calc;
#else
typedef struct Calc Calc;
#endif /* __cplusplus */
 
#endif 	/* __Calc_FWD_DEFINED__ */
 
 
/* header files for imported files */
#include "oaidl.h"
#include "ocidl.h"
 
#ifdef __cplusplus
extern "C"{
#endif 
 
 
#ifndef __ICalc_INTERFACE_DEFINED__
#define __ICalc_INTERFACE_DEFINED__
 
/* interface ICalc */
/* [unique][helpstring][uuid][object] */ 
 
 
EXTERN_C const IID IID_ICalc;
 
#if defined(__cplusplus) && !defined(CINTERFACE)
    
    MIDL_INTERFACE("FA9C0E6C-2E58-42DD-B7AF-349988D0F34A")
    ICalc : public IUnknown
    {
    public:
        virtual /* [local][helpstring] */ HRESULT STDMETHODCALLTYPE Add( 
            /* [in] */ LONG a,
            /* [in] */ LONG b,
            /* [out] */ LONG *c) = 0;
        
    };
    
#else 	/* C style interface */
 
    typedef struct ICalcVtbl
    {
        BEGIN_INTERFACE
        
        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
            ICalc * This,
            /* [in] */ REFIID riid,
            /* [iid_is][out] */ 
            __RPC__deref_out  void **ppvObject);
        
        ULONG ( STDMETHODCALLTYPE *AddRef )( 
            ICalc * This);
        
        ULONG ( STDMETHODCALLTYPE *Release )( 
            ICalc * This);
        
        /* [local][helpstring] */ HRESULT ( STDMETHODCALLTYPE *Add )( 
            ICalc * This,
            /* [in] */ LONG a,
            /* [in] */ LONG b,
            /* [out] */ LONG *c);
        
        END_INTERFACE
    } ICalcVtbl;
 
    interface ICalc
    {
        CONST_VTBL struct ICalcVtbl *lpVtbl;
    };
 
    
 
#ifdef COBJMACROS
 
 
#define ICalc_QueryInterface(This,riid,ppvObject)	\
    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
 
#define ICalc_AddRef(This)	\
    ( (This)->lpVtbl -> AddRef(This) ) 
 
#define ICalc_Release(This)	\
    ( (This)->lpVtbl -> Release(This) ) 
 
 
#define ICalc_Add(This,a,b,c)	\
    ( (This)->lpVtbl -> Add(This,a,b,c) ) 
 
#endif /* COBJMACROS */
 
 
#endif 	/* C style interface */
 
 
 
 
#endif 	/* __ICalc_INTERFACE_DEFINED__ */
 
 
 
#ifndef __ComServer32bLib_LIBRARY_DEFINED__
#define __ComServer32bLib_LIBRARY_DEFINED__
 
/* library ComServer32bLib */
/* [helpstring][version][uuid] */ 
 
 
EXTERN_C const IID LIBID_ComServer32bLib;
 
EXTERN_C const CLSID CLSID_Calc;
 
#ifdef __cplusplus
 
class DECLSPEC_UUID("06BEAE5A-BE01-438B-A2A4-DB4B6B8621FA")
Calc;
#endif
#endif /* __ComServer32bLib_LIBRARY_DEFINED__ */
 
/* Additional Prototypes for ALL interfaces */
 
/* end of Additional Prototypes */
 
#ifdef __cplusplus
}
#endif
 
#endif
 
///////////////// Calc.h ///////////////////////
 
// Calc.h : Declaration of the CCalc
 
#pragma once
#include "resource.h"       // main symbols
 
#include "ComServer32b_i.h"
 
 
#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif
 
 
 
// CCalc
 
class ATL_NO_VTABLE CCalc :
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CCalc, &CLSID_Calc>,
	public ICalc
{
public:
	CCalc()
	{
	}
 
DECLARE_REGISTRY_RESOURCEID(IDR_CALC)
 
DECLARE_NOT_AGGREGATABLE(CCalc)
 
BEGIN_COM_MAP(CCalc)
	COM_INTERFACE_ENTRY(ICalc)
END_COM_MAP()
 
 
 
	DECLARE_PROTECT_FINAL_CONSTRUCT()
 
	HRESULT FinalConstruct()
	{
		return S_OK;
	}
 
	void FinalRelease()
	{
	}
 
public:
 
	STDMETHOD(Add)(LONG a, LONG b, LONG* c);
};
 
OBJECT_ENTRY_AUTO(__uuidof(Calc), CCalc)
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:

Select allOpen in new window

 

by: EdAtCertFirstPosted on 2009-08-16 at 18:54:55ID: 25111264

A couple articles on the internet have code examples that do not work. VS2008 has different support for COM and ATL from the old VS 6.0 examples. There has to be a way of calling 32-bit code from 64-bit code. Does Microsoft have any documentation concerning this? MSDN does not seem to have a coherent discussion of this topic. Does anyone do this using Vista, Visual Studio 2008, unmanaged C++, COM, ATL?

Thanks,

Ed

 

by: EdAtCertFirstPosted on 2009-08-19 at 03:04:00ID: 25130982

Do the implementers at Microsoft in the Vista, WOW64, COM, registry, development areas monitor EE or does anyone know them and could send them a message to look at this question? Windows7 dropped the registry reflection mechanism, perhaps because of problems such as this one.

I have conferred with various COM experts who have written books, courses and taught COM/ATL and they have all moved on to .NET for the last 6 years or so and did not have any 64-bit experience with COM. One remembered a similar issue when the transition was from 16-bit to 32-bit.

I called MS support and they could not answer my questions and they said they do not have a way of sending issues into the developers. They did not charge my credit card the $79.

Since my out-of-process calls work 32-to-32 and 64-to-64, I figure this is a Microsoft bug or a documentation problem if there is a special call or parameter that would make this work.

If someone could get the Microsoft developers to look at this, maybe I can get a definitive answer.

Thanks,

Ed

 

by: EdAtCertFirstPosted on 2009-08-21 at 07:26:03ID: 25152114

 

by: EdAtCertFirstPosted on 2009-08-21 at 07:33:32ID: 25152194

COM/ATL books and course materials I used did not have the latest Visual Studio nuances. They also did not have the relatively new CLSCTX_ACTIVATE_32_BIT_SERVER parameter for CoCreateInstance and other methods:

      hr = CoCreateInstance(CLSID_AAServe, NULL, CLSCTX_LOCAL_SERVER | CLSCTX_ACTIVATE_32_BIT_SERVER, IID_IAAGetSet, (LPVOID*) &pGetSet);

Documenting this issue and solution here in EE and on MSDN C++ forum should help.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...