|
Hi Rajkumar, many thanks indeed for your help. What a relief, after a few attempts I came to a solution (see below). If it wasn't for the help of you guys from the Code Project forum, I would probably be stuck on these painful registry functions for months.. The "help" on MSDN and VS2005 might be ok as a reference only, but is totally useless unless you are an advanced programmer!
///// This code checks if a Value belonging to the opened Registry Key exists or not
unsigned long type=REG_SZ, size=1024;
char res[1024]="";
string MyChoiceVariable2;
HKEY key;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\..", NULL, KEY_READ, &key)==ERROR_SUCCESS)
{
if (ERROR_SUCCESS != RegQueryValueEx(key, "ValueName", NULL, &type, (LPBYTE)&res[0],&size))
{ MyChoiceVariable2 = "VALUE DOES NOT EXIST";
cout << MyChoiceVariable2 << endl;
}
if (ERROR_SUCCESS == RegQueryValueEx(key, "ValueName", NULL, &type, (LPBYTE)&res[0],&size))
{ MyChoiceVariable2 = "VALUE EXISTS";
cout << MyChoiceVariable2 << endl;
}
RegCloseKey(key);
}
|
|
|
|
|
J_E_D_I wrote: if (ERROR_SUCCESS != RegQueryValueEx(key, "ValueName", NULL, &type, (LPBYTE)&res[0],&size))
{ MyChoiceVariable2 = "VALUE DOES NOT EXIST";
cout << MyChoiceVariable2 << endl;
}
if (ERROR_SUCCESS == RegQueryValueEx(key, "ValueName", NULL, &type, (LPBYTE)&res[0],&size))
{ MyChoiceVariable2 = "VALUE EXISTS";
cout << MyChoiceVariable2 << endl;
}
have you heard about if...else.. clause in C++.
J_E_D_I wrote: RegCloseKey(key);
I appreciate your attempt to use the undiscussed RegCloseKey() API which is necessary.
|
|
|
|
|
J_E_D_I wrote: I get error C2065: 'hKey' : undeclared identifier. Have I missed something?
Yes. You've failed to declare a variable.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Hi guys,
I want to make an array that consists of system defined colors. I wrote the code
System::Drawing::Color Color1[]={Color::Black, Color::Brown, Color::Red};
what delivered the error
'System::Drawing::Color' : a native array cannot contain this managed type
Then I tried this version
Color Color1[] = __gc new Color[];
and I got this error
error C2440: 'initializing' : cannot convert from 'System::Drawing::Color ^' to 'System::Drawing::Color'
Has anyone an idea how to make this work?
Thanks and best wishes
|
|
|
|
|
Going from the 'System::Drawing::Color ^' I would guess that you'd get more help in the Managed C++ / CLI forum than here.
Certainly my help would be rubbish - I'm a MFC/Win32 fossil.
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
Click here[^]
May be it will help u .
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
Your choice for aks this question on this forum was wrong you must ask Managed C++/CLI[^].
|
|
|
|
|
Hi Experts,
I am creating a Shell Context menu application. When I right click on any folder or file, I display the path of file/folder.
I used the following code to get the path of selected files/folders:
<br />
<br />
void CCoMenHandler::GetSelectedFiles(LPCITEMIDLIST pidlFolder,IDataObject *pdtobj)<br />
{<br />
g_szSelectedFiles.RemoveAll();<br />
<br />
if (pdtobj) <br />
{<br />
pdtobj->AddRef();<br />
<br />
STGMEDIUM medium;<br />
FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};<br />
<br />
HRESULT hr = pdtobj->GetData (&fe, &medium);<br />
if (FAILED (hr))<br />
{<br />
GetRecycleBinFiles();
return ;<br />
}<br />
<br />
char path[MAX_PATH];<br />
<br />
UINT fileCount = DragQueryFile((HDROP)medium.hGlobal, 0xFFFFFFFF,<br />
path, MAX_PATH);<br />
<br />
if (fileCount>0)<br />
{<br />
g_szSelectedFiles.SetSize(fileCount);<br />
<br />
for (UINT i=0;i<fileCount;i++) <br />
{<br />
memset(path, 0, MAX_PATH);<br />
if (DragQueryFile((HDROP)medium.lpszFileName, i, path, MAX_PATH)) <br />
{<br />
g_szSelectedFiles.SetAt(i, path);<br />
}<br />
}<br />
<br />
g_szSelectedFiles.FreeExtra();<br />
}<br />
<br />
ReleaseStgMedium(&medium);<br />
}<br />
}<br />
<br />
But If I click on file shortcut(.lnk) file it displat the target path of file, although .lnk itself also a file.
I want to retrive shortcut (.lnk) file path.
|
|
|
|
|
Hello all,
I am developing application to open http connection.
I have used CInternetSession, CHttpConnection, CHttpFile to make Application.
My Code is as Bellow:
<br />
CInternetSession iSession;<br />
CHttpConnection *httpCon = iSession.GetHttpConnection(L"localhost", 80, L"", L"");<br />
CHttpFile *httpFile = httpCon->OpenRequest(L"POST", L"test/test.php"); <br />
BOOL x = httpFile->SendRequest();<br />
<br />
This code works fine for me.
Now the Problem is that i want to pass parameters using POST method to my request.
So is there anybody who can solve my problem.
Any help will be highly appreciated
Thanks.
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
|
Hi,
I have a application developed in Vc++ and C++, SQL as backend. This is an bit old application with dont have support for Unicode. Now we need to make this application to support Unicode.
This have to be done in VC++ n C++ and SQL DB. This program is of 300000 lines of code, which is divided into different small modules.
Can any help me out, how to make this application to support Unice code.
To my knowledge we have to replace char with wcahr or TChar (i m not sure which one to use). May need to do similar thing for DB as well.
Here what I would like to ask you is
1) Is there any specific procedure to do this conversion or we need to check each and every line for char and relace it with wchar/tchar.
Can you please help me to do this.
Thanks
|
|
|
|
|
Converting a project to Unicode[^]. There are totally 9 parts or so. That should help you.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Thank You Rajesh, It will be realy great if i can get some details with code exampls. Or if any one is there if u can share more knowledge for this conversion.
Thanks,
Maha
|
|
|
|
|
There isn't too much of code involved in the conversion. There are things like making neutral calls, using the _T macro, etc., Please go through all the parts of the tutorial I linked you to (there are 9 parts). That should get you through the task easily. But if you run into trouble somewhere in between, you discuss it with people here (by starting a new thread).
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Click here [^]
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
See this[^] link does any help?
|
|
|
|
|
Now i got clear idea about Unicode, but actually what the problem I am facing is, I am work in a real-time project. In this project we have more than 300000 lines of code; it will take hell lot of time if we want to do manual Unicode implementation. So please let me know if there are any tools available to do this Unicode conversion.
Also it will be great if you can give me some tips on how to perform unit testing for the Unicode implementation (is there any tool for this as well).
|
|
|
|
|
|
hi,
i have a popup window which i want to move behind an other window and appear from bottom of the other window. i work with SetWindowPosition() function, and also modify the other window as a top most window, but my popup window move upon that window.
would you please help me.
thanks a lot
Miss_F
|
|
|
|
|
Miss_F wrote: SetWindowPosition()
Are you talking about SetWindowPos() method? May be you should show us your code.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I put this code when the popup window is shown(in the popup class) (the other window which I want to put the popup movement behind it, is its owner and rect.bottom is the owner client rect bottom):
SetWindowPos( 0, 0, rect.bottom, 400, 100, SWP_NOZORDER | SWP_SHOWWINDOW );
GetOwner()->SetWindowPos( this , 0 , 0 , 0 , 0 , SWP_NOMOVE | SWP_NOSIZE );
// GetOwner()->SetWindowPos( &wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE );
for ( int i = 0 ; i <= rect.bottom ; i++ )
{
SetWindowPos( 0, 0, i, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_SHOWWINDOW);
RedrawWindow();
Sleep(100);
}
|
|
|
|
|
hi
i have a application to read text file and delete it .
up to reading i done it . now i want to delete the text file after reading .
can any one help me
k.guru moorthy
|
|
|
|
|
Try DeleteFile()
BOOL WINAPI DeleteFile(
__in LPCTSTR lpFileName
);
BTW, don't delete your question(s) when your problem is solved.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
|