I have a small problem that is driving me insane.. this makes no sense to me at all.

I'm using the RegCreateKeyEx call to create some registry keys. The functions work fine in other parts of my program, but in one part, it fails.

Here's the call:

lngCreateKeyResults = RegCreateKeyEx(HKEY_CU, strNewKey, 0, 0&, REG_NONVOLATILE, FULLACCESS, DEFAULTSECURITY, lngRegKey, lngDisposition)

I have verified all of my constants, so the values should be just fine.

Here's the kicker..

This call works, IF I do it in the immediate window.. however, at runtime, lngCreateKeyResults ends up being error 87 - invalid paramaters. I can break right after it fails, copy and paste the call into the immediate window, and it works.

Any ideas???????

VB 6.0 SP4, Enterprise Edition

Thanks for any help!!