CeRegOpenKeyEx fails with -2147467256

G

Guest

Does any one have trouble with CeRegOpenKeyEx
I get an error : -2147467259 and I can't figure out what it is
I am using the following code

result = CeRegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\.NETCompactFramework", 0, 0, &hKey)

char msg[1024]
LPVOID lpMsgBuf;
if( FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, result, 0, (LPTSTR) &lpMsgBuf, 0, NULL) == 0

sprintf(msg, "%s ", (LPCSTR)lpMsgBuf);
MessageBox( NULL, msg, "Error Message", MB_OK )
// Free the buffer.
LocalFree( lpMsgBuf );


result comes back as -2147467259, and the only string I am able to get back from FormatMessage is "PE" ... :

Any ideas what I should be looking at
All other RAPI seem to work fine.
 
G

Guest

Wow I foudn out that this might be a timing issue
I found out through testing that if I put a MessageBox(...) call prior to the CeRegOpenKeyEx() call, things work fine. Then I tried putting a Sleep(3000) instead of a MessageBox and it works as well
Is this possible
Could it be that the RAPI initialization needs some more time to completely initialize

Thank
----- fhunter wrote: ----

Does any one have trouble with CeRegOpenKeyEx
I get an error : -2147467259 and I can't figure out what it is
I am using the following code

result = CeRegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\.NETCompactFramework", 0, 0, &hKey)

char msg[1024]
LPVOID lpMsgBuf;
if( FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, result, 0, (LPTSTR) &lpMsgBuf, 0, NULL) == 0

sprintf(msg, "%s ", (LPCSTR)lpMsgBuf);
MessageBox( NULL, msg, "Error Message", MB_OK )
// Free the buffer.
LocalFree( lpMsgBuf );


result comes back as -2147467259, and the only string I am able to get back from FormatMessage is "PE" ... :

Any ideas what I should be looking at
All other RAPI seem to work fine.
 
C

Chris Tacke, eMVP

Absolutely if you're connecting asnchronously.

-Chris


fhunter said:
Wow I foudn out that this might be a timing issue?
I found out through testing that if I put a MessageBox(...) call prior to
the CeRegOpenKeyEx() call, things work fine. Then I tried putting a
Sleep(3000) instead of a MessageBox and it works as well.
Is this possible?
Could it be that the RAPI initialization needs some more time to completely initialize?

Thanks
----- fhunter wrote: -----

Does any one have trouble with CeRegOpenKeyEx ?
I get an error : -2147467259 and I can't figure out what it is.
I am using the following code:

result = CeRegOpenKeyEx(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\.NETCompactFramework", 0, 0, &hKey);
char msg[1024];
LPVOID lpMsgBuf;
if( FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, result, 0,
(LPTSTR) &lpMsgBuf, 0, NULL) == 0 )
{
sprintf(msg, "%s ", (LPCSTR)lpMsgBuf);
MessageBox( NULL, msg, "Error Message", MB_OK );
// Free the buffer.
LocalFree( lpMsgBuf );
}

result comes back as -2147467259, and the only string I am able to
get back from FormatMessage is "PE" ... :(
 
G

Guest

No no, in this case everything is synchronous.


----- Chris Tacke, eMVP wrote: ----

Absolutely if you're connecting asnchronously

-Chri


fhunter said:
I found out through testing that if I put a MessageBox(...) call prior t
the CeRegOpenKeyEx() call, things work fine. Then I tried putting
Sleep(3000) instead of a MessageBox and it works as well
Is this possible
Could it be that the RAPI initialization needs some more time t completely initialize
Thank ----- fhunter wrote: ----
Does any one have trouble with CeRegOpenKeyEx
I get an error : -2147467259 and I can't figure out what it is
I am using the following code
result = CeRegOpenKeyEx(HKEY_LOCAL_MACHINE L"SOFTWARE\\Microsoft\\.NETCompactFramework", 0, 0, &hKey)
char msg[1024]
LPVOID lpMsgBuf
if( FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, result, 0
(LPTSTR) &lpMsgBuf, 0, NULL) == 0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top