|
ytsau wrote: Does anybody know how to get the string in C++ program?
Just read it from the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks for all the replies!
How do I read the registry? Can you show me the actual C code?
Thanks again!
|
|
|
|
|
ytsau wrote: How do I read the registry?
Use RegQueryValueEx() .
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks a lot!
Here is the actual code I figured out to access the ProductID:
UCHAR buf[256];
ULONG size = 256;
ULONG type = REG_SZ;
HKEY hKey;
RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hKey);
RegQueryValueEx(hKey, L"ProductId", NULL, &type, buf, &size );
RegCloseKey(hKey);
|
|
|
|
|
Great. The only change I would suggest is:
ULONG size = sizeof(buf); That way if you need to change the size of buf , you only have to do it in one spot.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Just read it from the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductId
It should be considered that another sibling key path -- "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\ProductId" -- seems to be more version-independent.
|
|
|
|
|
Viorel. wrote: It should be considered that another sibling key path -- "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\ProductId" -- seems to be more version-independent.
The General tab of the System Properties dialog does not look at that key.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi
I am working with dialog based application. Below is the snapshot of first part of dialog class of my project.
class CFileSenderDlg : public CDialog<br />
{<br />
public:<br />
CFileSenderDlg(CWnd* pParent = NULL);
void setStatus(CString);
enum { IDD = IDD_FILESENDER_DIALOG };<br />
CString filePath;<br />
CString status;<br />
<br />
protected:<br />
virtual void DoDataExchange(CDataExchange* pDX);
and so on.
But i am recieving an error on
enum { IDD = IDD_FILESENDER_DIALOG };
And that is
error C2065: 'IDD_FILESENDER_DIALOG' : undeclared identifier
error C2057: expected constant expression
Can anyone please tell me why this error occurs.
Thank you
We Believe in Excellence
www.aqueelmirza.cjb.net
-- modified at 8:34 Tuesday 6th June, 2006
|
|
|
|
|
wrote:
error C2065: 'IDD_FILESENDER_DIALOG' : undeclared identifier
Can anyone please tell me why this error occurs.
include "resource.h" file
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Thanks for responding. I tried it but now it is displaying "Debug Assertion Failed" dialog. and when i try to debug it, it is at following line in afxwin1.inl
_AFXWIN_INLINE HINSTANCE AFXAPI AfxGetResourceHandle()<br />
{ ASSERT(afxCurrentResourceHandle != NULL);
Can you please tell me why it is.
Thank you
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
This is just a guess, but are you trying to create the dialog in some other class's constructor? (My guess is the CWinApp-derived one). If that is the case, then put it elsewhere.
this is this.
|
|
|
|
|
how to create your class?
whitesky
|
|
|
|
|
Aqueel wrote: AFXWIN_INLINE HINSTANCE AFXAPI AfxGetResourceHandle()
{ ASSERT(afxCurrentResourceHandle != NULL);
Can you please tell me why it is.
This may due to incorrect sequence of including of headers
Include the resource.h into application's class Header...
This may resolve the problem.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
I have made my project using MFC AppWizard so resource.h was automatically included.
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Didn't you use ClassWizard to create the project, or the CFileSenderDlg class? It would have handled the resource.h file for you. Otherwise, you'll need to look in that file to make sure there are no duplicate IDs.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I have made it using MFC AppWizard. It was working perfectly fine untill i included some files in my project. I needed them for my network programming.
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
I got a point here. I have included a header file named server.h and a source file server.cpp in my project. When i try to include my CFileSenderDlg.h that is dialog class in server.h, i recieve that error. But i need to include dialog class in server.c-pp. What should i do?
Thank you
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Do you have #include "stdafx.h" at the top of server.cpp ? Do you have #include "stdafx.h" and #include "resource.h" at the top of CFileSenderDlg.cpp ?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Yes i have.
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Then I'm not sure where the problem lies. Sorry.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
im not sure but i think you have two problems because if your problem was include you get
error C2065 but you get another error error C2057
whitesky
|
|
|
|
|
When i add MSHTML.h file in any application there is shows some error in this file.
syntax error : identifier 'LONG_PTR' i really cannot get what is this error is for what should i include other than this file.
Shikha
Pune
|
|
|
|
|
Shikha Jain wrote: identifier 'LONG_PTR'
identifier LONG_PTR what ????? undefined ? symbol unknown ?
what is the compilation error number, and exact message please ????
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
I think it is defined in basetsd.h header. Just include that header, and it should be fine.
In the Microsoft SDK, it is defined as:
typedef _W64 long LONG_PTR, *PLONG_PTR;
As you can see it is a long in disguise.
this is this.
|
|
|
|
|
Can you be more specific whats application type?
whitesky
|
|
|
|