If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

CreateInstance fails on xp

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.

Re: CreateInstance fails on xp

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.

Re: CreateInstance fails on xp

Originally Posted by ovidiucucu

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.

And don't forget to call RegCloseKey to close the key opened by RegOpenKeyEx.

Re: CreateInstance fails on xp

Originally Posted by VictorN

And don't forget to call RegCloseKey to close the key opened by RegOpenKeyEx.

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

Re: CreateInstance fails on xp

Originally Posted by ovidiucucu

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

Re: CreateInstance fails on xp

Originally Posted by 2kaud

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

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.