|
I realized what I was doing wrong.
I'm using a memDC so there is no window associated with the underlying DC.
I apologize for my oversight.
|
|
|
|
|
Hamid. wrote: Hi CPallini
Happy New Year
I wanted to send the card postal for you but I didnt have your mail address but anyway I wish good year with health for you and your family
I'm sorry, but the link for the above message, is broken hence I cannot reply to the right place. Anyway I'm happy about your message and I wish you and your family a Happy New Year.
Best Wishes Again,
Carlo.
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.
[my articles]
|
|
|
|
|
can anybody tell me
What happens if an exception is throws from an, object's constructor and object's destructor?
thanks in dvance
|
|
|
|
|
Ask George_George: he made a extensive study about...
Seriously, IMHO opinion, the object consumer has to care about of that possibility exactly like it does with standard method thrown exceptions. A difference maybe the fact that object construction/destruction sometimes happens implicitly (and is somehow hidden to the consumer itself).
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.
[my articles]
|
|
|
|
|
[1] Constructor
The object will never be created. Destructor is NOT called. If you allocated ressources before the exception is thrown, they are NOT freed.
[2] Destructors
Technically, the object is left in an undefined state. Likely, Accessing it afterwards will fail, and resources may leak.
Practically, destructors should NEVER throw. It violates even the most basic exception safety guarantee: that objects remain destructable, no matter what.
For lots of more information, try the GOTW columns[^] that deal with exceptions
|
|
|
|
|
Hi all:
I have the following linked list in which head always pointed the last queue item. I'm thinking about the possibility to make the head points to the begining of the queue with the least possible changes.
<br />
class CQueue1 {<br />
public:<br />
CQueue1(int nIndex);<br />
static CQueue1* sm_pHead;<br />
CQueue1* m_pNext; <br />
};<br />
CQueue1* CQueue1::sm_pHead = NULL;<br />
CQueue1::CQueue1(int nIndex)<br />
{<br />
m_pNext = sm_pHead;
sm_pHead = this;
}<br />
Thanks,
|
|
|
|
|
|
Change it as follows
CQueue1::CQueue1(int nIndex)<br />
{<br />
CQueue1** pLast = &sm_pHead;<br />
while( 0 != *pLast )<br />
{<br />
pLast = &((*pLast)->m_pNext);<br />
}<br />
*pLast = this;<br />
m_pNext = 0;<br />
}
|
|
|
|
|
It is better to avoid the while loop
|
|
|
|
|
hai all
HKEY_CURRENT_USER\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\ logon User Name cannot access from system process I use the following code
LPCSTR szKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer");
LPCSTR szValueName = _T("Logon User Name");
//open the registry key
lRet = RegOpenKeyEx( HKEY_CURRENT_USER, szKey, 0, KEY_QUERY_VALUE, &hSubKey );
if( lRet == ERROR_SUCCESS)
{
dwBufLen = 256;
lRet = RegQueryValueEx( hSubKey, szValueName, NULL, NULL,
(LPBYTE) szValue, &dwBufLen);
}
pls help me
Advance thanks
|
|
|
|
|
vicky00000 wrote: LPCSTR szKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer");
LPCSTR szValueName = _T("Logon User Name");
The above should be
LPCTSTR szKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer");
LPCTSTR szValueName = _T("Logon User Name");
And the code shown lacks some definitions like the one of the buffer (probably they are already present in your program, I don't know), anyway, the following code (practically identical to yours) is working fine on my system (XP):
TCHAR szValue[256];
LPCTSTR szKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer");
LPCTSTR szValueName = _T("Logon User Name");
HKEY hSubKey;
LRESULT lRet = RegOpenKeyEx( HKEY_CURRENT_USER, szKey, 0, KEY_QUERY_VALUE, &hSubKey );
if( lRet == ERROR_SUCCESS)
{
DWORD dwBufLen = 256;
Ret = RegQueryValueEx( hSubKey, szValueName, NULL, NULL,(LPBYTE) szValue, &dwBufLen);
}
BTW whenever RegQueryValueEx fails is worthy to give a look at reported error.
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.
[my articles]
|
|
|
|
|
Thanks ur reply,
My code is exactly like u mentioned. This code will work correctly while it run by a normal process . It shows error while it run as system process. The error it shows is ERROR_FILE_NOT_FOUND
|
|
|
|
|
vicky00000 wrote: t shows error while it run as system process
Do you mean a service?
vicky00000 wrote: The error it shows is ERROR_FILE_NOT_FOUND
MSDN http://msdn2.microsoft.com/en-us/library/ms724911(VS.85).aspx[^] states:
If lpValueName specifies a key that is not in the registry, the function returns ERROR_FILE_NOT_FOUND.
Hence the service is not able to se this entry (or the entry there isn't when the service runs). But those are only poor hypothesis: I'm not an expert about, maybe you can also ask the OS/SysAdimn forum.
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.
[my articles]
|
|
|
|
|
So what's failing?
"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
|
|
|
|
|
Did you get any error or null result?
|
|
|
|
|
In the registry, the current user would be the account you're running from -
the system account.
See LocalSystem Account[^]
Are you trying to get the name of the current logged-on user
from a service running in a system account?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Did you look into this[^]?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
I have 80 lines in a text file with 30 values each line separated by a white space (some are ints, doubles and another strings). I have made a routine with fscanf() to read each line and store the values I need. But I only need 7 of the 30 values to store them in an array, so , for instance, I want to store the first data, and the second and third, then skip the next 4 values, store the next and so on.
Is there a way to skip entries with fscanf function?
Thank you.
|
|
|
|
|
José Luis Sogorb wrote: Is there a way to skip entries with fscanf function?
Oh yes. Simply read unwanted entries and then discard them.
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.
[my articles]
|
|
|
|
|
Yes, but I have to read the unwanted data and assign them a place to store them and then discard?
There are 23 unwanted entries in each line, and there are 80 lines. This is what I dont want to do.
|
|
|
|
|
Well you haven't accumulate the garbage data. You may use a restricted set of variables (one for each different data type).
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.
[my articles]
|
|
|
|
|
What's wrong with:
for (int x = 0; x < 80; x++)
{
fscanf(...);
if (some_condition)
{
}
}
"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
|
|
|
|
|
<br />
for (int i=0; i<1000; i++)<br />
{<br />
if(FALSE == LoadBitmap(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDB_BITMAP)))<br />
{<br />
AfxMessageBox("error");<br />
} <br />
<br />
}<br />
these code would error when i around six hundred, maybe 632, may be 654...
why?
|
|
|
|
|
Call GetLastError to get additional info.
Anyway, the following maybe an hint (from MSDN http://msdn2.microsoft.com/en-us/library/ms532309.aspx[^])
If the bitmap pointed to by the lpBitmapName parameter does not exist or there is insufficient memory to load the bitmap, the function fails.
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.
[my articles]
|
|
|
|