i created an com client that try to create com server with the command CreateInstance.
at win 7 it works fine (both 32 and 64 bit).
but with xp it fails.
someone know what is the problem?
i created the app with win 7 - 64 bit.
Printable View
i created an com client that try to create com server with the command CreateInstance.
at win 7 it works fine (both 32 and 64 bit).
but with xp it fails.
someone know what is the problem?
i created the app with win 7 - 64 bit.
How does it fail?
Could you show your code?
1. CreateInstance is a function, not a command.
2. With no other details, nobody can guess what's your problem. Not even looking in a crystal ball... :)
MyBlLib::IMyServPtr m_spSrv;
hr = m_spSrv.CreateInstance(MyBlLib::CLSID_MyServ);
hr return with -2147221164
with WIN 7 it works fine (both 32 and 64 bit)
It means:
Quote:
80040154 error indicates REGDB_E_CLASSNOTREG, or "class not registered."
thanx Victor, you right.
the problem was with function RegDeleteKeyValue that win xp doesn't support.
do you know how can i delete registry key value at win xp? (didn't find it at google..?)
RegDeleteValue -?
See also Registry Functions in MSDN.
Unlike RegDeleteValue, RegDeleteKeyValue has an extra argument, lpSubKey.
Indeed, it requires at least Windows Vista / Server 2008.
If your target system is Windows XP and older, replace RegDeleteKeyValue with RegOpenKeyEx (to open the sub-key), followed by RegDeleteValue.
And don't forget to handle errors, to avoid further misleading situations.
Other possible replacement for RegDeleteKeyValue is SHDeleteValue function,
Of course, thanks Victor! :)
One additional note: if your target OS is Windows XP and later, to avoid using newer functions which are not supported on XP, go to targetver.h or stdafx.h (depending on VS version) and set WINVER and _WIN32_WINNT values to 0x0501.
Example
Code:#ifndef WINVER // Allow use of features specific to Windows XP or later.
#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
But surely if you do this using guards and if WINVER/_WIN32_WINNT are already defined you may still compile code for functions not supported on XP? Wouldn't it be better that if WINVER or _WIN32_WINNT are already defined, to undefine these and then explicity define them to be the required values like this
Code:#pragma once
#ifdef WINVER
#undef WINVER
#endif
#define WINVER 0x0501
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT WINVER