I need some help please!

For everyone, just starting with C++ or programming at all. Ask newbie questions in this forum!

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

I need some help please!

Postby alienoiz » Tue Apr 24, 2012 6:06 am

Hi ppl,

i´m new here and i dont understand almost nothing about coding (just a bit of VB), i just read a try to understand the codes of this and that and apply them to my needs (i will not be a help to you)...but...well... im trying to create a .dll file that i want to read a specific registry entry key and if returns true initialize a function. This is what i have for now:

#include ".\Float.h"


REGISTER_GUI_PLUGIN( Float, L"My Float" );

Float::Float( IMpUnknown* host ) : MpGuiBase(host)
{
HKEY hkey;
DWORD dwDisposition;

if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("Software\\Mydll"), (123), NULL, 0, 0, NULL, &hkey, &dwDisposition))
{

floatVal.initialize( this, 0, static_cast<MpGuiBaseMemberPtr>(&Float::onSetFloatVal) );

RegCloseKey(hkey);
}

boolVal.initialize( this, 1, static_cast<MpGuiBaseMemberPtr>(&Float::onSetBoolVal) );
}


void Float::onSetFloatVal()
{
boolVal = floatVal;
}

void Float::onSetBoolVal()
{

}

This code is to be executed in the Synthedit VST visual programming software as a module of its kind...

well...ive tried various conditions but the line:

floatVal.initialize( this, 0, static_cast<MpGuiBaseMemberPtr>(&Float::onSetFloatVal) );

always is executed even when there is no registration of "MyDll" in the registry!

Any help?

Thank You!

Duarte V.
alienoiz
 
Posts: 38
Joined: Tue Apr 24, 2012 6:02 am

Re: I need some help please!

Postby exomo » Tue Apr 24, 2012 12:00 pm

Several things are wrong.

First you don't use the code tags. Please put you code in [ code ] and [/ code ] tags (without the spaces) to make it more readable.
Second you should look a close look at the documentation when you use functions you don't know.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724844%28v=vs.85%29.aspx
It says "Creates the specified registry key. If the key already exists, the function opens it."
And about the return value:
"If the function succeeds, the return value is ERROR_SUCCESS.

If the function fails, the return value is a nonzero error code defined in Winerror.h. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error."
That means the return value doesn't tell you if the key existed or not, if it doesn't exist it is created.

The third parameter is Reserved "This parameter is reserved and must be zero.". So why do you pass 123? This value is most likely ignored, but you should pass 0 just to be sure.
The parameter you want to use is the last one, lpdwDisposition. You should check the value of your dwDisposition variable to see if the key was created or opened. Of course you should also check the return value to see if there was an error. If there was an error you have to do something else because the other values are not valid.
Who needs a signature anyway.
User avatar
exomo
 
Posts: 881
Joined: Fri Sep 26, 2003 12:30 pm
Location: germany->baden

Re: I need some help please!

Postby alienoiz » Tue Apr 24, 2012 2:47 pm

tkx...in the mean while, i got my code in some help tuturials...but thanks anyway... sorry for not insert the code in the [code]/[code/]...im not used to this....like i said ...i normaly lursk in internet for tuturials and parts of code to help myself...im no real coder..im just trying to make a small thing, but i have never coded in c++ before (only VB)..it has been a while to get this right but i made it for now....i yet have a lot to develope for my objectives but the rest gonna be in VB....once again Thanks for you time!

Regards:

Duarte V.
alienoiz
 
Posts: 38
Joined: Tue Apr 24, 2012 6:02 am


Return to For Beginners

Who is online

Users browsing this forum: No registered users and 4 guests