|
not any of the parameters are garbage, after executing this, if i see in the registry the "Value name" is garbage. that too it will set the "Value Name" if i run in "Debug" mode, the problem is there only if i make the exe in "Release" mode.
|
|
|
|
|
Yashusid wrote: not any of the parameters are garbage,
Then why would you state, "the 'Value Name' for hDckey is some garbage?" If none of the arguments being passed to RegSetValueEx() contain garbage, then what exactly is the problem?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
oops sorry if it created confusion....my intention was to convey that...
i have a key...for that key i am setting a property...
my registry entry for key
when u see in registry
Name ------------ Type ----Data
(garbage here)--- REG_SZ -- test.xml --> ------Release mode
test--------------REG_SZ -- test.xml --> ------Debug mode
i am getting garbage in Name field for the key...
|
|
|
|
|
Yashusid wrote: i am getting garbage in Name field for the key...
Which would indicate that lpResName is wrong. Try:
TCHAR s[128];
_tcscpy(s, GetSourceName(RegFileName));
rCode = RegSetValueEx(hDckey,
s,
0,
REG_SZ,
(LPBYTE) RegFileName,
(DWORD) (_tcslen(RegFileName) + 1) * sizeof(TCHAR));
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You are great!!!
Thanks a lot!!!
It works........
but please help me in understaning why it was setting correctly in "Debug" mode ?
|
|
|
|
|
Yashusid wrote: but please help me in understaning why it was setting correctly in "Debug" mode ?
It's not. You just got lucky. Read here for the differences in the two.
You should now be concerned as to what GetSourceName() is doing (wrong). If the code is short enough, post it and we can take a look.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
In GetSourceName i am parsing a XML file.
char *GetSourceName(char *RegFileName)
{
LPTSTR lpstrMsg;
CoInitialize(NULL);
CComPtr<ixmldomdocument> spXMLDOM;
CComPtr<ixmldomnode> spXMLNode;
IXMLDOMAttribute *pIXMLDOMAttribute = NULL;
IXMLDOMElement *pIXMLDOMElement = NULL;
HRESULT hr = spXMLDOM.CoCreateInstance(__uuidof(DOMDocument));
VARIANT_BOOL bSuccess = false;
USES_CONVERSION;
_variant_t fileNameValue=T2W(RegFileName);
hr = spXMLDOM->load(fileNameValue,&bSuccess);
if(!hr)
{
hr = spXMLDOM->get_documentElement(&pIXMLDOMElement);
_variant_t nameValue;
if(!hr)
{
hr = pIXMLDOMElement->getAttribute(CComBSTR(L"source-name"),&nameValue);
}
if ( nameValue.vt == VT_BSTR )
{
USES_CONVERSION;
lpstrMsg = W2T(nameValue.bstrVal);
}
}
spXMLDOM.Release();
CoUninitialize();
return lpstrMsg;
}
|
|
|
|
|
The memory that lpstrMsg points to is no longer valid when GetSourceName() goes out of scope. Return a CString or string object instead. Or you could leave it as is, and make the appropriate change to all places that use GetSourceName() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
This is a weird solution.. you might be aware of this.
here Format will automatically round the value.
Here advantage is you can specify decimal places you are interested in. accordingly format will round values after that decimal place.
CString str;
double d=1.516;
str.Format("%0.2lf",d);
|
|
|
|
|
inline double round(double x){
const double y = floor(x);
if(x-y<0.5) return y;
else return y+1;
}
Do not use casting to int if x is very big, because int value range is smaller than double range.
I don't know if it is possible to implement this function in a faster way, but i use it and it work propely.
Russell
|
|
|
|
|
I'm moving datas from old dbf files. But now a need to access them but the perform of "select * from dbftable for xCond" command is too slow. How can I access its file with the CDX index?. I'm using oledb and VC++ 6.
|
|
|
|
|
Hello community,
how to recive an cookie from the web,
i have an application to open a url and show the content in browser object,
now i like to recive a cookie if posible from this url, how to do this?
thanks
termal
|
|
|
|
|
termal wrote: recive a cookie if posible from this ur
See if CInternetSession::GetCookie(/*parameters*/); suits your needs.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hello,
i try this, but i got a error:
ERROR_INTERNET_UNRECOGNIZED_SCHEME
12006
The URL scheme could not be recognized, or is not supported.
Is here any sample for this?
thanks
termal
|
|
|
|
|
termal wrote: now i like to recive a cookie if posible from this url, how to do this?
Try InternetGetCookie() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello,
thanks for reply, i try to use this funktion!
regards
termal
|
|
|
|
|
the scenario is I am counting down 5, if no 'y' has been input during this time, then it ends at one way, else it ends at another way. Because I dont expect there must be a 'y' input, I write this as multi-thread, one for counting down, one for checking the 'y' input (could be unnecessary).
this program works fine when I put it at the foreground(using linux), but when put it at background, error happens, it will stop and wait for getchar() input, and m doesnot count down. As long as I use shell command "fg" to bring it back to foreground, the count down resumes, but that is not what I want.
what I want is just: put the program execution at background, while waiting for a 'y' input during 5 seconds count down time.
<br />
void *countdown( );<br />
void *waitinput( );<br />
static int m=5;<br />
static int k=1;<br />
<br />
int main(int argc, char **argv)<br />
{<br />
<br />
pthread_t thread1=0, thread2=0;<br />
int iret1=0, iret2=0;<br />
<br />
<br />
<br />
iret1 = pthread_create( &thread1, NULL, countdown, NULL);<br />
iret2 = pthread_create( &thread2, NULL, waitinput, NULL);<br />
<br />
<br />
<br />
<br />
<br />
pthread_join( thread1, NULL);<br />
<br />
pthread_cancel(thread1);<br />
pthread_cancel(thread2);<br />
printf("pthread been cancelled\n\n");<br />
<br />
if(k=1){...}<br />
else {...}<br />
<br />
<br />
return 0;<br />
}<br />
<br />
void *countdown()<br />
{<br />
while(m>0)<br />
{<br />
printf("%d seconds left\n",m--);<br />
sleep(1);<br />
printf("m is %d\n",m);<br />
}<br />
<br />
}<br />
<br />
void *waitinput()<br />
{<br />
char c='n';<br />
while(m)<br />
{<br />
if((c=getchar())=='y')<br />
{<br />
printf("congratulations. you entered y\n");<br />
sleep(1);<br />
m=0;k=0;<br />
}<br />
else ;<br />
}<br />
}<br />
|
|
|
|
|
bloodwinner wrote: pthread_create( &thread1, NULL, countdown, NULL);
A stab in the dark, since I do not know anything about Linux, but maybe you need to set one of these to something else than just NULL to get it to act independently of having or not the focus.
|
|
|
|
|
thank you for reply.
1.I guess it does not have much thing to do with the platform.
2.Regarding to the parameters of pthread, I took reference from here http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html#BASICS
it looks working fine, at least as I said when executing it at the foreground,
but because I can open only one terminal, probably have to do several things, so I can only put it running at the background, there problems occurs.
|
|
|
|
|
I think that you should bring in another class that handles your threads - one that holds back the return of the main.
main(...)
{
ClassThreads = new clsClassThreads();
do
{
existCondition = ClassThreads->Start();
if (existCondition)
{
ClassThreads->getResults();
//do something with thread results.
ShowMessage("Thread class done. Exiting loop and Main");
}else{
ShowMessage("Thread class not done yet. Restarting threads");
}
}while(!exitCondition)
delete ClassThreads;
return 0;
}
|
|
|
|
|
errr....
I am only using C, so could you give me some information related to it?
|
|
|
|
|
Sorry - Im was wrong - the fact that it works in foreground i missed. Ignore my posting. I thought you had a code design issue.
Well, other guy suggested the os. I would say the same. And i think it is something you'll find in Linux articles. I don't know C threads and linux in the detail you might need.
|
|
|
|
|
I'm Frustrated. in .NET a easy Control.Add(new TextBox()) will create a textbox during runtime.
Do anyone know of a way to add controls to a panel during runtime? (or form)
And also may someone point me to some litrature that *explains* the advanced methods with respect to controls and control containers in C++ VCL?
Appreciate it
|
|
|
|
|
You can use of Create or CreateWindow or you can declare a variable for example CButton m_button; m_Button.Create(...); and after create it declare events for it.
|
|
|
|
|
In addition to WhiteSky's reply...
Everything you ever wanted to know (and more) about Windows controls can be found here:
Individual Control Information[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|