|
Try the following:
static PWSTR pszKeyName = L"Software\\ABCD\\ABCD UD PCL6_00-00-00-00-00-00\\printer_ui\\icc_profile";
LONG lResult;
HKEY hkMyKey;
DWORD dwDisposition;
DWORD dwType;
DWORD dwData;
DWORD dwSize;
lResult = RegCreateKeyEx(HKEY_CURRENT_USER,
pszKeyName,
0,
NULL,
0,
KEY_READ,
NULL,
&hkMyKey,
&dwDisposition
);
if (ERROR_SUCCESS == lResult)
{
dwSize = sizeof dwData;
lResult = RegGetValue(hkMyKey,
L"0",
L"szResId",
RRF_RT_ANY,
&dwType,
&dwData,
&dwSize
);
}
Note: this is a Win32 solution, I don't have access to a 64-bit system.
It's time for a new signature.
|
|
|
|
|
Richard MacCutchan wrote: static PWSTR pszKeyName = L"Software\\ABCD\\ABCD UD PCL6_00-00-00-00-00-00\\printer_ui\\icc_profile";
I think you should make pszKeyName constant (i.e. static LPCWSTR), considering you're referencing it to memory (the string literal) that could be read-only.
|
|
|
|
|
MicroVirus wrote: I think you should make pszKeyName constant (i.e. static LPCWSTR), considering you're referencing it to memory (the string literal) that could be read-only.
This is a simple example of how to get a value from a registry key; making the keyname const will have no effect on the code I provided.
It's time for a new signature.
|
|
|
|
|
Richard MacCutchan wrote: This is a simple example of how to get a value from a registry key; making the keyname const will have no effect on the code I provided.
True, but it's still good to realise that it should be const. If someone reads your post and decides to adapt it, having it to const to begin with could be useful.
I know, I'm whining... It's just that I feel it's an overlooked detail; I forget it myself, so that's why I find it important
|
|
|
|
|
The last parameter is wrong. It needs to be a pointer to a DWORD that gives the size of the buffer, not the size of the buffer itself. Currently, your code is using the value of the memory at address 200 as the buffer size, and that could be anything...
Try:
DWORD cbSize = 200;
RegQueryValueEx(hKey, pszEntry, NULL, NULL, (LPBYTE)pData, &cbSize);
|
|
|
|
|
hello guys...im new to MFC using VS 2008.....i get the file opend but the sound file does't play, why??....here is the code im using
void CPlaySoundDlg::OnOpennplay()
{
CFile file;
char strFilter[] = {"All Files (*.*)|*.*"};
CFileDialog FileDlg(TRUE,".WAV",NULL,0,strFilter);
CString filename = _T(FileDlg.GetFileName());
CString filepath = _T(FileDlg.GetFolderPath());
if (FileDlg.DoModal()==IDOK) {
PlaySound(filepath + filename,NULL,SND_SYNC);
}
}
How can I know that which item i present in which header file...just like File Open/Save dialogs are present in afxdlgs.h??
|
|
|
|
|
Why do you query the file name and the folder separately and then concatenate them, are you sure this produces a valid path (correctly separated with backslashes)? Use CFileDialog::GetPathName[^] instead. Not to mention you are querying these strings BEFORE you display the dialog to the user, so most likely you get 2 empty strings anyways. Those Get... things will give you something usefull once the dialog has been dismissed via OK. Another thing, _T() is used on string literals, not on CString objects returned by some functions.
Muzammil Saeed wrote: How can I know that which item i present in which header file...just like File Open/Save dialogs are present in afxdlgs.h??Confused
- What do you mean by this?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
1)..As stated earlier, im new to this, next time I"ll use seggested functions i-e GetPathName().
2)..In order to use Open FileDialog / Save File Dialog, w mus incluse afxdlgs.h file (which off course is te required header file), how can I know that which header file to include b4 using something?? I mean where find header files to choose from??
|
|
|
|
|
If you have a "standard" MFC project created for you by Visual Studio then most common things like the CFileDialog you can access freely without explicitly needing to include anything because the headers for these things are included (directly or indirectly) inside stdafx.h which will be included in your cpp files anyways. If for some reason you DO need to add includes explicitly you can check MSDN[^], search for the class or method or whatever you want to use and check its documentation, also, you can google for it, e.g:
1. Google for CFileDialog[^]
2. Click the first hit (it's usually MSDN if you are looking for common MFC/Microsoft things)
3. scroll down till you see this: " Header: afxdlgs.h ", this info is mostly located around the bottom of the page, somethimes there's even a table showing you what header you need to include, what library/DLL contains the implementations, etc.
Another way is to simply hit F1 while the cursor is on what you are looking for, this should give you the documentation for it which should state the header. Also another way is to right-click what you are looking for and select "Go to declaration", if you are lucky it will bring you to the header you need to include to use the given item.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
|
Yourwelcome.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
You should use getpathname method.
or
change code with
PlaySound(filepath +"\\"+ filename,NULL,SND_SYNC);
|
|
|
|
|
Hi all,
i m taking help of this article for printing in my application.
Another ListView print (preview) sample.[^]
but some times in 64 bit machine Print and Print Function not responding.
when i debug the code i found in OnPreparePrinting(CPrintInfo* pInfo) function DoPreparePrinting(pInfo) return false.
but this problem is resolve when i restart the machine.
please tell me how can i resolve the problem without restarting the machine.
thanks in advance.
modified on Monday, July 19, 2010 2:57 AM
|
|
|
|
|
If I open one named pipe and want to communicate both ways between client and server, how do keep the client from reading data it just wrote to the pipe? Or is the data only transfered in one direction, that that the client cannot end up reading the data it writes?
For example: Client writes a string, then assume the server reads the string, so it checks the pipes for a response, then ends up reading the string it just wrote to the pipe.
|
|
|
|
|
AFAIK it is like two uni-directional pipes, similar to a serial port communication.
|
|
|
|
|
The situation cannot happen. One "end's" writes are the other "end's" reads.
|
|
|
|
|
CreateNamedPipe api used to create namedpipes provide you with option duples,inbound or outbound
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
dene99970 wrote: Client writes a string, then assume the server reads the string, so it checks the pipes for a response, then ends up reading the string it just wrote to the pipe.
This should never happen, as previously pointed out. There is a probably a bug in your source code or the "server" echos back received text, can you show example code?
/M
|
|
|
|
|
hello guys...im new to MFC using VS 2008. How can I get the radio buttons status in MFC using VS 2008??
|
|
|
|
|
read the documentation and have a look at CButton::GetCheck[^].
M.
Watched code never compiles.
|
|
|
|
|
BOOL bSelected = (CButton*) GetDlgItem(IDC_XYZ))->GetCheck();
--
"Programming is an art that fights back!"
|
|
|
|
|
GetCheck returns an int in case the radio or more probably the checkbox is a 3 state button; so if you only want to see if it's checked, do something like :
BOOL bSelected = (CButton*) GetDlgItem(IDC_XYZ))->GetCheck() == BST_CHECKED;
(but I'm only nitpicking).
Watched code never compiles.
|
|
|
|
|
Maximilien wrote: BOOL bSelected = (CButton*) GetDlgItem(IDC_XYZ))->GetCheck() == BST_CHECKED;
(but I'm only nitpicking).
While we are picking nits... GetDlgItem() actually returns a pointer to a CTempWnd* object if there is no entry in the internal MFC permanent CHandleMap. The only reason why this code does not cause an access violation is because CButton::GetCheck() is an __inlined SendMessage(m_hWnd,BM_GETCHECK...
You should avoid upcasting a pointer returned from GetDlgItem().
Best Wishes,
-David Delaune
|
|
|
|
|
Randor wrote: You should avoid upcasting a pointer returned from GetDlgItem().
To add to the nitpicking that is exactly what the documentation[^] recommends that you do.
It's time for a new signature.
|
|
|
|
|
Richard MacCutchan wrote: that is exactly what the documentation[^] recommends that you do.
An additional nit to pick: The upcast in the documentation is completely pointless... GotoDlgCtrl[^] takes a pointer to a CWnd* object. The CWnd* pointer returned by GetDlgItem would suffice. The MSDN documentation is full of bad sample codes.
Best Wishes,
-David Delaune
|
|
|
|