|
Glad I could help.
0100000101101110011001000111001011101001
|
|
|
|
|
I am trying to use registry to store some common application data.
Here is my test code
SetRegistryKey(_T("*CCC*"));
{
CString strSection = "1234";
CString strStringItem = "My String Item";
CString strIntItem = "My Int Item";
CWinApp* pApp = AfxGetApp();
pApp->WriteProfileString(strSection, strStringItem, "test");
CString strValue;
strValue = pApp->GetProfileString(strSection, strStringItem);
ASSERT(strValue == "test");
pApp->WriteProfileInt(strSection, strIntItem, 1234);
int nValue;
nValue = pApp->GetProfileInt(strSection, strIntItem, 0);
ASSERT(nValue == 1234);
}
The "problem" is - I cannot see the *CCC* in the registry until the WriteProfileString is executed and application name .ini file is build in c:\windows directory.
Even then the GetProfileString reads the data from ini file and not the registry.
And in registry I have a application name key added.
How did it get there ?
I found lots of registry wrappers here , but I need just basic API explanations, not a wrapper class.
Ideally I do not want to build ini file, so how do I do that?
I need a better description , than MSDN, for SetRegistryKey.
I do not get MSDN explanations about working in either ini or registry.
Sample code to write / read to / from registry without building ini file would be nice ( in VC++ not VB ) .
Any constructive help will be as always appreciated.
Thanks Vaclav
|
|
|
|
|
Vaclav_Sal wrote: The "problem" is - I cannot see the *CCC* in the registry until the WriteProfileString is executed and application name .ini file is build in c:\windows directory.
Do you see anything about your app in the HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\IniFileMapping key?
Vaclav_Sal wrote: And in registry I have a application name key added.
Do you see this in the HKCU\Software\*CCC* key?
Vaclav_Sal wrote: I found lots of registry wrappers here , but I need just basic API explanations, not a wrapper class.
CWinApp is a wrapper class.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
David,
thanks for your help.
It looks like SetRegistryKey(_T(strSection));
works fine ( I can read the value in regedt32 ) after my app has been run once, but not until than.
So if I wamt to check for correct registry entries and if not there write them using SetRegistryKey I cannot read it immediately back in InitInstance, but somewhere else should work OK.
I did read one of the registry articles here to find out that registry
creates stuff if you check for it and it is not there.
I'll do some more reading to find out more abut this. Maybe this is where the application is being inserted in, since I specify only the section.
I did check the HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\IniFileMapping for my app and did not find anything there.
I am not that concern about getting the app into the registry but sure would like to know where is it coming from. I guess I could scan for the string and delete it to see when it goes away, if it does.
|
|
|
|
|
Vaclav_Sal wrote: I found lots of registry wrappers here , but I need just basic API explanations, not a wrapper class.
Despite your following comment I always find that MSDN[^] is the best place to look.
|
|
|
|
|
Hello
I want to ask information via keyboard the user. I did a dialog with edit control, this dialog let me to ask the name of the file when the user will kept information.
I made this, but not run
Code:
void CDlgResultados::OnBnClickedButton1()
{
CDlgSaveLoad dlgSL1;
if(dlgSL1.DoModal()==IDOK)
{
dlgSL1.GetDlgItemText(IDC_EDIT1, nombre);
}
SaveToFile();
}
App is in mfc.
The error appear in dlgSL1.GetDlgItemText(IDC_EDIT1, nombre);
|
|
|
|
|
(I will only give partial answer, just to get you going... look for tutorials/sample/example for more complete code and/or documentation)
You cannot access dialog control before a DoModal (the controls are not created yet) or after a DoModal (the control were destroyed).
In your dlgSL1 dialog code, add a CString variable and "attach" it to the CEdit (IDC_EDIT1) with DDX_Control with something like:
DDX_Control(pDX, IDC_EDIT1, m_YouStringVariable);
This can be done manually or with the wizard or the properies (I think); when that is working properly, you can set/get the variable from the parent dialog (in your case: CDlgResultados::OnBnClickedButton1)
if(dlgSL1.DoModal()==IDOK)
{
nombre= dlgSL1.m_YourStringVariable;
}
Another way is to override the CDialog::OnOK in the CDlgSaveLoad class and in there, you can get the string from the CEdit and put it in an intermediate variable:
void CDlgSaveLoad::OnOK()
{
m_YourEdit.GetWindowText(m_YourStringVariable);
CDialog::OnOK();
}
and the code in CDlgResultados::OnBnClickedButton1 will be similar as above.
Max.
Watched code never compiles.
|
|
|
|
|
|
Thank you very much.
+ 10 for the answer.
Here is the answer :
void CDlgSaveLoad::OnBnClickedOk()
{
CDialogEx::OnOK();
m_Edit.GetWindowText(m_strData);
}
void CDlgResultados::OnBnClickedButton1()
{
CDlgSaveLoad mDlg;
if ( mDlg.DoModal() == IDOK )
{
nombre= mDlg.getData();
}
SaveToFile();
}
|
|
|
|
|
Swap the two lines in OnBnClickedOk .
and I assume that
nombre= mDlg.getData();
will return m_strData ?
Watched code never compiles.
|
|
|
|
|
Yes, I forgot write here the method :
public:
CString getData() const { return m_strData; }
|
|
|
|
|
I'm sorry, I have another question.
When I show something in Edit control, it appear selected in hightlight blue, how can I modify it??
I'd like that only appear the text but not hightlight
|
|
|
|
|
antonio343 wrote: When I show something in Edit control, it appear selected in hightlight blue, how can I modify it??
have a look at CEdit::SetSel[^]
M.
Watched code never compiles.
|
|
|
|
|
Ok, but I didn't call this function in my code, and the text appear selected blue when I show the text.
I don't want that the text appear selected
I use to show and get the text GetDlgItemText/SetDlgItemText
Could be this the problem?
|
|
|
|
|
I think that the problen is setfocus() I call this function an it select all the text. I need that the text will be showed without higlight
|
|
|
|
|
Hello Friends
we are creating A desktop based application.And mine application is based on other 3rd application Engine or Enviorement which is having their own Activation code.
So,installation is like that first we will install 3rd application with their activation code.Now,i want to install mine application that will secure 3rd application activation also and also make sure that mine desktop application will be used only on one machine.
I want to secure 3rd application activation because If somehow I make secure mine application and then mine application gets corrupt or expire after trial then that 3rd application will remain on user system.So,I want to secure both through some user Input Activation code or through some other way.
Any Ideas??
Regards
Yogesh
|
|
|
|
|
This is the C/C++/MFC forum.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
What kind of activation code are you giving away with the 3rd party software, an "evalulation / trial license" or a "premanent license"?
|
|
|
|
|
You probably mean this and perhaps this too.
Here's a list of software license/product key articles.
|
|
|
|
|
Thanks A Lot to all of you.
Regards
Yogesh
|
|
|
|
|
Hi all,
I have made a report style list control. In that list control i have made two columns.
What i want to do is when column 2 value changes to certain number then column 1 value should change into hyperlink.
how can i do this.
Thanks in advance
|
|
|
|
|
What event causes column 2 to change? You need to monitor or capture that, and make the changes to column 1 at the appropriate time. Without knowing more about your code it is difficult to be more specific.
|
|
|
|
|
both columns have been initialized with some values
when initial value of column 2 increases then column one value should become hyperlink.
Thanks.
|
|
|
|
|
|
for static controls: here
|
|
|
|