|
ok, i've tried this code, but i cant figure out how to display 'cchValue'. any ideas?
thanks in advance,
sam kline
TCHAR achKey[MAX_KEY_LENGTH];
DWORD cbName;
TCHAR achClass[MAX_PATH] = TEXT("");
DWORD cchClassName = MAX_PATH;
DWORD cSubKeys=0;
DWORD cbMaxSubKey;
DWORD cchMaxClass;
DWORD cValues;
DWORD cchMaxValue;
DWORD cbMaxValueData;
DWORD cbSecurityDescriptor;
FILETIME ftLastWriteTime;
HKEY hKey;
DWORD i, retCode;
char temp[9999];
TCHAR achValue[MAX_VALUE_NAME];
DWORD cchValue = MAX_VALUE_NAME;
RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\name\\something"), 0, KEY_QUERY_VALUE, &hKey);
retCode = RegQueryInfoKey(
hKey,
achClass,
&cchClassName,
NULL,
&cSubKeys,
&cbMaxSubKey,
&cchMaxClass,
&cValues,
&cchMaxValue,
&cbMaxValueData,
&cbSecurityDescriptor,
&ftLastWriteTime);
for (i=0, retCode=ERROR_SUCCESS; i<cValues; i++)
{
cchValue = MAX_VALUE_NAME;
achValue[0] = '\0';
retCode = RegEnumValue(hKey, i, achValue, &cchValue, NULL, NULL, NULL, NULL);
if (retCode == ERROR_SUCCESS )
{
sprintf(temp, "%d: %s - ", i, achValue);
somelistbox.AddString(temp);
}
}
RegCloseKey(hKey);
-- modified at 10:55 Saturday 18th February, 2006
|
|
|
|
|
You can use this function:
Here you have to pass the valueName to access it's value.
Specify the Root key where your subkey is located
CString YourClassName::GetValueFromRegistry(CString regValuName)
{
char lszValue[255];
CString str ;
HKEY hKey;
LONG returnStatus;
DWORD dwType=REG_SZ;
DWORD dwSize=255;
returnStatus = RegOpenKeyEx(HKEY_CURRENT_USER, "currentuser\\software\\name\\program", 0L, KEY_ALL_ACCESS, &hKey);
if (returnStatus == ERROR_SUCCESS)
{
returnStatus = RegQueryValueEx(hKey,regValuName, NULL, &dwType,(LPBYTE)&lszValue, &dwSize);
if(returnStatus == ERROR_SUCCESS)
{
str = (LPCTSTR)lszValue;
}
else
{
str="";
}
}
else
{
str="";
}
RegCloseKey(hKey);
return str;
}
Cheers
"Peace of mind through Technology"
|
|
|
|
|
oh, i just realized that that code worked!
thanks a lot!
sam kline
|
|
|
|
|
Hi everybody,
I want to include few external DLL files into my executable file as a static Library.
Microsoft Visual C++ can do that with MFC,my question is: How can I do to insert external DLL's files?
I hope any body can help me!
Thanks
aLx
aLx
|
|
|
|
|
@LX wrote: I want to include few external DLL files into my executable file as a static Library.
That is not possible.
John
|
|
|
|
|
|
OK, let the world be more "friendly" to this guy (or gal?)... If you want to do that with say MYDLL.DLL, then you must locate (or steal or beg or borrow or build) the .LIB file MYDLL.LIB. If you have the source code of MYDLL.DLL, then building the LIB file is a piece of cake. After you get the LIB file, link it statically by adding it to the Link tab of Project settings (do not forget to add its path to the Library path list in Tools --> Options --> Directories).
If you do not have (or cannot get) the LIB file, you cannot do it.
Koushik Biswas
|
|
|
|
|
Hi. Can anyone tell me how I can establish the "Class Name" for my application's window?
I want to use the FindWindow API that looks like this: LONG FindWindowA(class, title) .
What I want to do for my C++ app, MyCPPApp.exe, is establish the "Class Name" to be something like "JohnsApp".
I have used Spy++ to look at other Class Names,
XLMAIN - MS Excel
OpusApp - Word97
...
I also want to use FindWindowA( ) to send messages between two applications.
Thanks,
Johnny
|
|
|
|
|
john john mackey wrote: I have used Spy++ to look at other Class Names...
Ok, so what does it indicate for your application's window?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
It gives some generic name like,
AfxFrameOrView
Since I don't understand, it could be possible that there may exist other windows of this same class (that I don't want to attach to.)
So, I still would like to be able to set my own Class Name for my application/window.
Thanks,
Johnny
|
|
|
|
|
So just use AfxRegisterClass() to register a new class name of your liking.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Thanks! I'll look into this function.
Best regards,
Johnny
|
|
|
|
|
Sending messages between two applications or instances of the same application can be tricky business, so be warned. Here are a few ideas:
a)
You could use FindWindow() with a NULL class name. That will return the handle of any window that has the specified Window name. This is only useful if you know your window name is unique to your application and your application does not change the window title, for example to include the name of the file currently open.
b)
You could use the GetClassName() API function to obtain the class name at runtime. I notice with MFC, though, that it creates a new window class for every instance of the application. That's one serious bummer - it means you cannot predict what the class name of another instance of the same application will be.
c)
The easiest way I can think of to send messages between applications is to first register a unique message with ::RegisterWindowMessage() . You then use SendMessage() with a HWND value of HWND_BROADCAST to send the message to every top-level window in the system, as in:
<br />
UINT uMyOwnWndMessage = ::RegisterWindowMessage(_T("SomeSillyMessage"));<br />
...<br />
::SendMessage(HWND_BROADCAST, uMyOwnWndMessage, 42, 0x4A);<br />
You register the message at the very beginning of your application. If another instance has already registered the message you will get the same message ID value. Obviously you should pick a unique message "name", otherwise the chance exists that another application may have already registered a message with the same name and the end result will be chaos.
Be careful with sending messages between applications, though. You cannot send messages containing pointers. That includes string pointers (LPCTSTR and LPTSTR). The second instance will receive the message but the pointer will be meaningless outside the context of the instance that created the pointer. Sending window handles should be OK but be careful with child windows.
You could also use the WM_COPYDATA message to send string data (and other stuff) accross, but then again you will need to know HWND of the destination window ... and you still have the pointer issue.
d)
You could register you own window class with ::RegisterClass() and create a hidden window using this class that can serve as a type of "proxy" for your messages. Not all too easy to implement, though.
e)
Consider using a more "controlled" form of IPC, like shared memory or a named pipe to communicate between instances of an app.
– Johannes de Rek
|
|
|
|
|
Example: Key in 234 ==> two hundred and thirty four.
key in 1000==> one thousand.
key in 2040==> two thousand and forty.
|
|
|
|
|
There are dozens of examples on the Internet of how to convert money (or currency) to words. Here is one.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
int main()
{
char ID[100],name[100];
int amount, a[10];
cout<<"Please enter your details below:\n"<<;
cout<<" name of payee(with no space between word.Ex:christine_gan)"<<endl;
cin>>name;
cout<<endl<<"Please enter ID number of payee(Ex:840125025961)"<<endl;
cin>>ID;
cout<<endl<<"Please enter the amount (Ex:100)"<<endl;
cin>>amount;
cout<<endl<<"This is the cheque with given details \n\n\n\n\n\n\n\n\n\n\n" ;
cout<<"Shanghai Bank Berhad,Shanghai,89000"<<endl<<endl<<endl;
cout<<"Payee: "<<name<<setw(6)<<"("<<ID<<")"<<setw(20)<<"$ "<<amount<<endl;
cout<<" _____________________________________"<<endl<<endl;;
cout<<"amount: ";
if ((amount%10)!=0)
{
a[0]=amount%10;
}
else if((amount/10)!=0)
{
a[1]=amount/10;
a[0]=amount%10;
}
else if((amount/100)!=0)
{
a[2]=amount/100;
a[1]=(amount/10)%10;
a[0]=amount%10;
}
else ((amount/1000)!=0);
{
a[3]=amount/1000;
a[2]=(amount/100)%10;
a[1]=(amount/10)%10;
a[0]=amount%10;
}
if(a[0]==0 && a[1]==0 && a[2]==0)
{
switch (a[3])
{
case 9: cout <<"nine thousand ";break;
case 8: cout <<"eight thousand ";break;
case 7: cout <<"seven thousand ";break;
case 6: cout <<"six thousand ";break;
case 5: cout <<"five thousand ";break;
case 4: cout <<"four thousand ";break;
case 3: cout <<"three thousand ";break;
case 2: cout <<"two thousand ";break;
case 1 :cout <<"one thousand ";break;
}
}
else
{
switch (a[3])
{
case 9: cout <<"nine thousand ";break;
case 8: cout <<"eight thousand ";break;
case 7: cout <<"seven thousand ";break;
case 6: cout <<"six thousand ";break;
case 5: cout <<"five thousand ";break;
case 4: cout <<"four thousand ";break;
case 3: cout <<"three thousand ";break;
case 2: cout <<"two thousand ";break;
case 1 :cout <<"one thousand ";break;
}
if ((a[1]==0 && a[2]==0)||a[2]==0||(a[0]==0 && a[1]==0))
{
switch (a[3])
{
case 9: cout <<"and ";break;
case 8: cout <<"and ";break;
case 7: cout <<"and ";break;
case 6: cout <<"and ";break;
case 5: cout <<"and ";break;
case 4: cout <<"and ";break;
case 3: cout <<"and ";break;
case 2: cout <<"and ";break;
case 1 :cout <<"and ";break;
}
}
if(a[0]==0 && a[1]==0)
{
switch (a[2])
{
case 9: cout <<"nine hundred ";break;
case 8: cout <<"eight hundred";break;
case 7: cout <<"seven hundred";break;
case 6: cout <<"six hundred";break;
case 5: cout <<"five hundred";break;
case 4: cout <<"four hundred";break;
case 3: cout <<"three hundred";break;
case 2: cout <<"two hundred";break;
case 1 :cout <<"one hundred";break;
}
}
else
{
switch (a[2])
{
case 9: cout <<"nine hundred and ";break;
case 8: cout <<"eight hundred and ";break;
case 7: cout <<"seven hundred and ";break;
case 6: cout <<"six hundred and ";break;
case 5: cout <<"five hundred and ";break;
case 4: cout <<"four hundred and ";break; case 3: cout <<"three hundred and ";break;
case 2: cout <<"two hundred and ";break;
case 1 :cout <<"one hundred and ";break;
}
if (a[1]==1)
{
switch (a[0])
{
case 9: cout <<"nineteen";break;
case 8: cout <<"eighteen";break;
case 7: cout <<"seventeen";break;
case 6: cout <<"sixteen";break;
case 5: cout <<"fifteen";break;
case 4: cout <<"fourteen";break;
case 3: cout <<"thirteen";break;
case 2: cout <<"twelve";break;
case 1 :cout <<"eleven";break;
case 0 :cout <<"ten";break;
}
}
else
{
switch (a[1])
{
case 9: cout <<"ninety ";break;
case 8: cout <<"eighty ";break;
case 7: cout <<"seventy ";break;
case 6: cout <<"sixty ";break;
case 5: cout <<"fifty ";break;
case 4: cout <<"fourty ";break;
case 3: cout <<"thirty ";break;
case 2: cout <<"twenty ";break;
}
switch (a[0])
{
case 9: cout <<"nine";break;
case 8: cout <<"eight";break;
case 7: cout <<"seven";break;
case 6: cout <<"six";break;
case 5: cout <<"five";break;
case 4: cout <<"four";break;
case 3: cout <<"three";break;
case 2: cout <<"two";break;
case 1: cout <<"one";break;
}
}
}
}
cout<<" Dollar Only"<<endl;
cout<<" _____________________________________"<<endl;
return 0;
}
|
|
|
|
|
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
int main()
{
char ID[100],name[100];
int amount, a[10];
cout<<"Please enter your details below:\n"<<;
cout<<" name of payee(with no space between word.Ex:christine_gan)"<<endl;
cin>>name;
cout<<endl<<"Please enter ID number of payee(Ex:840125025961)"<<endl;
cin>>ID;
cout<<endl<<"Please enter the amount (Ex:100)"<<endl;
cin>>amount;
cout<<endl<<"This is the cheque with given details \n\n\n\n\n\n\n\n\n\n\n" ;
cout<<"Shanghai Bank Berhad,Shanghai,89000"<<endl<<endl<<endl;
cout<<"Payee: "<<name<<setw(6)<<"("<<ID<<")"<<setw(20)<<"$ "<<amount<<endl;
cout<<" _____________________________________"<<endl<<endl;;
cout<<"amount: ";
if ((amount%10)!=0)
{
a[0]=amount%10;
}
else if((amount/10)!=0)
{
a[1]=amount/10;
a[0]=amount%10;
}
else if((amount/100)!=0)
{
a[2]=amount/100;
a[1]=(amount/10)%10;
a[0]=amount%10;
}
else ((amount/1000)!=0);
{
a[3]=amount/1000;
a[2]=(amount/100)%10;
a[1]=(amount/10)%10;
a[0]=amount%10;
}
if(a[0]==0 && a[1]==0 && a[2]==0)
{
switch (a[3])
{
case 9: cout <<"nine thousand ";break;
case 8: cout <<"eight thousand ";break;
case 7: cout <<"seven thousand ";break;
case 6: cout <<"six thousand ";break;
case 5: cout <<"five thousand ";break;
case 4: cout <<"four thousand ";break;
case 3: cout <<"three thousand ";break;
case 2: cout <<"two thousand ";break;
case 1 :cout <<"one thousand ";break;
}
}
else
{
switch (a[3])
{
case 9: cout <<"nine thousand ";break;
case 8: cout <<"eight thousand ";break;
case 7: cout <<"seven thousand ";break;
case 6: cout <<"six thousand ";break;
case 5: cout <<"five thousand ";break;
case 4: cout <<"four thousand ";break;
case 3: cout <<"three thousand ";break;
case 2: cout <<"two thousand ";break;
case 1 :cout <<"one thousand ";break;
}
if ((a[1]==0 && a[2]==0)||a[2]==0||(a[0]==0 && a[1]==0))
{
switch (a[3])
{
case 9: cout <<"and ";break;
case 8: cout <<"and ";break;
case 7: cout <<"and ";break;
case 6: cout <<"and ";break;
case 5: cout <<"and ";break;
case 4: cout <<"and ";break;
case 3: cout <<"and ";break;
case 2: cout <<"and ";break;
case 1 :cout <<"and ";break;
}
}
if(a[0]==0 && a[1]==0)
{
switch (a[2])
{
case 9: cout <<"nine hundred ";break;
case 8: cout <<"eight hundred";break;
case 7: cout <<"seven hundred";break;
case 6: cout <<"six hundred";break;
case 5: cout <<"five hundred";break;
case 4: cout <<"four hundred";break;
case 3: cout <<"three hundred";break;
case 2: cout <<"two hundred";break;
case 1 :cout <<"one hundred";break;
}
}
else
{
switch (a[2])
{
case 9: cout <<"nine hundred and ";break;
case 8: cout <<"eight hundred and ";break;
case 7: cout <<"seven hundred and ";break;
case 6: cout <<"six hundred and ";break;
case 5: cout <<"five hundred and ";break;
case 4: cout <<"four hundred and ";break; case 3: cout <<"three hundred and ";break;
case 2: cout <<"two hundred and ";break;
case 1 :cout <<"one hundred and ";break;
}
if (a[1]==1)
{
switch (a[0])
{
case 9: cout <<"nineteen";break;
case 8: cout <<"eighteen";break;
case 7: cout <<"seventeen";break;
case 6: cout <<"sixteen";break;
case 5: cout <<"fifteen";break;
case 4: cout <<"fourteen";break;
case 3: cout <<"thirteen";break;
case 2: cout <<"twelve";break;
case 1 :cout <<"eleven";break;
case 0 :cout <<"ten";break;
}
}
else
{
switch (a[1])
{
case 9: cout <<"ninety ";break;
case 8: cout <<"eighty ";break;
case 7: cout <<"seventy ";break;
case 6: cout <<"sixty ";break;
case 5: cout <<"fifty ";break;
case 4: cout <<"fourty ";break;
case 3: cout <<"thirty ";break;
case 2: cout <<"twenty ";break;
}
switch (a[0])
{
case 9: cout <<"nine";break;
case 8: cout <<"eight";break;
case 7: cout <<"seven";break;
case 6: cout <<"six";break;
case 5: cout <<"five";break;
case 4: cout <<"four";break;
case 3: cout <<"three";break;
case 2: cout <<"two";break;
case 1: cout <<"one";break;
}
}
}
}
cout<<" Dollar Only"<<endl;
cout<<" _____________________________________"<<endl;
return 0;
}
|
|
|
|
|
dannysoo2020 wrote: else ((amount/1000)!=0);
This will obviously not work.
Your code does not indicate what trouble you are having. Instead of checking from smallest to largest, it would make more sense to check from largest to smallest. Have you single-stepped through it to see where things go awry?
In addition to the Java example I already provided, here is another. If you have a Basic background, see here.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
I just wanna the amount till 9999, can it make it easier, cos i saw the code in both you gave still very complicated for me to see, sorry.
|
|
|
|
|
This should be a rough estimate:
const char *tens[] =
{
{ "twenty " }, { "thirty " },
{ "fourty " }, { "fifty " },
{ "sixty " }, { "seventy " },
{ "eighty " }, { "ninety " },
};
const char *teens[] =
{
{ "ten " }, { "eleven " },
{ "twelve " }, { "thirteen " },
{ "fourteen " }, { "fifteen " },
{ "sixteen " }, { "seventeen " },
{ "eightteen " }, { "nineteen " },
};
const char *ones[] =
{
{ "one " }, { "two " },
{ "three " }, { "four " },
{ "five " }, { "six " },
{ "seven " }, { "eight " },
{ "nine " }
};
string NumToText( unsigned int uNumber )
{
string strResult;
unsigned int uTemp;
if (uNumber >= 1000U)
{
uTemp = uNumber / 1000U;
strResult += ones[uTemp - 1];
strResult += string("thousand ");
uNumber = uNumber - (uTemp * 1000U);
}
if (uNumber >= 100U)
{
uTemp = uNumber / 100U;
strResult += ones[uTemp - 1];
strResult += "hundred ";
uNumber = uNumber - (uTemp * 100U);
}
if (uNumber >= 20U)
{
uTemp = uNumber / 10U;
strResult += tens[uTemp - 2];
uNumber = uNumber - (uTemp * 10U);
}
if (uNumber >= 10U)
{
uTemp = uNumber;
strResult += teens[uTemp - 10];
}
else if (uNumber >= 1U)
{
strResult += ones[uNumber - 1];
}
return strResult;
}
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Any suggestions (or code snippets) that can help me build a tree from given, random paths (not necessarily existing ones, could be this\dimwit\cannot\work\that\out, what\a\doofus, etc).
The root item has already been taken care of and I'm just trying to show the (possible) connections between the directories, but I'm just going round in circles, instead of laterally.
redsagentsven
|
|
|
|
|
|
I'm not exactly sure what you are asking about here. Are you wanting to create a directory hierarchy? If so, does CreateDirectory() or SHCreateDirectoryEx() help?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Hi,
Does anyone know how to implement the save workspace as in Visual C++ in your MDI application. That is on restart of the app, reload all the child frames that were visible during the previous run of the app.
Thanks
Vijay
|
|
|
|
|
I have no idea about macintosh..
Programs that are made with VS6 can run on macintosh? If not, how can someone code a program in a mac?
|
|
|
|
|