|
Thank you Baron I'll check it.
|
|
|
|
|
The user running your application doesn't have permission to create registry entries, would be my guess.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
But I can create registry entries manually but unable to create through code in some systems
If Admin privilages would be the problem how do i give permission to create registry entries through code?
The code what i have written is:
DWORD dwMaxLength = MAX_COMPUTERNAME_LENGTH + 1;
char szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
GetComputerName(szComputerName, &dwMaxLength);
HKEY hHeadKey;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Database", 0, KEY_QUERY_VALUE,&hHeadKey) == ERROR_SUCCESS)
TRACE("Key exists in registry");
else if (RegConnectRegistry(szComputerName,HKEY_LOCAL_MACHINE,&hHeadKey) == ERROR_SUCCESS)
{
HKEY hSubKey1, hSubKey2;
if (RegCreateKeyEx(hHeadKey,"SOFTWARE\\Database",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hSubKey1,NULL) == ERROR_SUCCESS)
{
CString str = "SOME TEXT";
RegSetValueEx(hSubKey1,"Key1",0,REG_SZ,(const unsigned char *)(LPCSTR)str,str.GetLength() + 1);
}
if (RegCreateKeyEx(hHeadKey,"SOFTWARE\\Database",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hSubKey2,NULL) == ERROR_SUCCESS)
{
CString str = "SOME TEXT";
RegSetValueEx(hSubKey2,"Key2",0,REG_SZ,(const unsigned char *)(LPCSTR)str,str.GetLength() + 1);
}
}
|
|
|
|
|
I haven't dug very deep into your code, but everyone of the registry functions returns an error code; use it, it would probably tell you what the error is.
Use the TRACE macro to know where it fails and what the error code is. For your own convenience I suggest you also use ::FormatMessage(...) and write the system error message instead of a hex number. See here[^].
Are you able to connect to the remote registry where it doesn't work and what OS version is running on the remote system?
OT: please use the <pre> tags when you're posting code.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Thank you for the suggestion.
The OS where I am creating registry entries is Windows NT.
|
|
|
|
|
requesting the regsam=KEY_ALL_ACCESS will fail if your user is not an administrator.
This behavior is modified on Vista but that's a story for another day...
|
|
|
|
|
Hello,
Suppose I have
vector<CString>StringVector
vector<int>IntVector
If I have above strutures in my program then do I need to worry that CString will take up variable number of bytes for each member of the vector and it may cause problems while accessing data in the vector
As otherwise each member in the IntVector is going to take up equal number of bytes so accessing member from IntVector is fine.
Please tell me whether I should take care while making a vector of CStrings .
Prithaa
|
|
|
|
|
prithaa wrote: Please tell me whether I should take care while making a vector of CStrings
Use 'iterator's for accessing the objects stored in the vector and forget about the difficulties in accessing those..
Do your Duty and Don't expect the Result Rate this Post, if I helped You
|
|
|
|
|
No, you don't have to worry about that because the CString object contain a pointer to the real buffer array.
But I'm wondering why you are using CString with the STL ? Why don't you use std::string to keep consistent ?
|
|
|
|
|
because std::vector is better than MFC's containers maybe ?!
|
|
|
|
|
toxcct wrote: because std::vector is better than MFC's containers maybe ?!
Yes, but I said: Why don't you use std::string to keep consistent ?
|
|
|
|
|
because CString is easier to use than std::string ?
|
|
|
|
|
Errr... Well, I don't have anything more to add
|
|
|
|
|
Cedric Moonen wrote: Errr... Well, I don't have anything more to add
thanksfully, cause i didn't have further arguments either
|
|
|
|
|
Hello,
May be I am repeating myself
If I have vector<CString>
Will reallocation occur when there is change
in size of CString?
Will the entire operation O(n) take more time in reallocation thereby being expensive performance wise?
You said that I should not worry about memory allocation
but will that affect my performance and calculations if there are any
Prithaa
|
|
|
|
|
Can anyone please help, how do you send an entire file using client/server and a dll....
|
|
|
|
|
What DLL ?
What about recv and send ?
|
|
|
|
|
bbvnvbnbnbnbn wrote: client/server and a dll....
No. Send it through DHL. It is faster and reliable.
|
|
|
|
|
I have a server which is waiting for connection requests. When it gets a connection request from a remote client CMySocket::OnAccept() is being called ...then there i want to know the client IP Address from which the request is coming. Is it possible?
Thank you.
KIRAN PINJARLA
|
|
|
|
|
Inside OnAccept(..), call
Accept(CAsyncSocket& rConnectedSocket, SOCKADDR* lpSockAddr, int* lpSockAddrLen);
if Accept succeeded then, lpSockAddr will have the IP address of the connecting machine.
Hope CMySocket is CAsyncSocket
Do your Duty and Don't expect the Result Rate this Post, if I helped You
|
|
|
|
|
Thank you Parthi,
But i want to know from which the connection request is generated, and according to the rights they have i will decide to accept or reject. Is there a way to do this?
KIRAN PINJARLA
|
|
|
|
|
If the protocol is TCP then the only information you have is the remote peer's IP address (as
"seen" by your server). Any authentication you'll have to do yourself.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi
I want to explain the situation that I am in trouble then I will ask a question.I have four dialog boxes (Dlg1,Dlg2,Dlg3,childDlg).Each of Dlg1,Dlg2 and Dlg3 has a edit box and a button.The buttons are creating the childDlg and childDlg is sending a string for edit box of the dialog box which created the childDlg.But I couldn't find which one created the childDlg.I am using this line to get parent:
Dlg1 *dlg1 =(Dlg1 *) GetParent();
But I cannot find if it is Dlg1,Dlg2 or Dlg3.How can we do that?
I have another problem.Can we set a pointer to the edit box of the dialog box which created childDlg?Because the names of member variables which were declared for edit boxes are different.
I think about a complex solution but I know it is a very bad programming.Maybe you can find a simple solution.
|
|
|
|
|
You can distinguish the windows by their handles. BTW you can also pass some kind of identifier to the dialog, before calling the DoModal method (you can define you own method, for instance SetParent , in your childDlg class).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
The CDialog constructor accepts a pointer to the parent window. Doing it like this should be all you need:
<br />
void CMyDialog::DoSomething()<br />
{<br />
CMyOtherDlg dlg(this);<br />
dlg.DoModal();<br />
}<br />
If you don't pass in a parent window pointer (for modal dialogs), I believe MFC apps assume that the parent is the main app window itself.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|