|
grassrootkit wrote: I could rather manipulate that the key in pretranslate() itself right?
Should be fine
grassrootkit wrote: What could be the reason here?
I don't know - but Spy++ could tell you if the dialog's getting the WM_KEYDOWN messages?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Okay I'll check them up. Thanks for your responses.
|
|
|
|
|
Hi,
How to install the vs 2008 trial edition after download from mircosoft?
|
|
|
|
|
Looks like your OS lost a handler for "Space" KeyDown? Your subject looks like a train.
samuellhu wrote: How to install the vs 2008 trial edition after download from mircosoft?
You need to stay online. It downloads from their server.
|
|
|
|
|
I am writing an application that enumerates all the subkeys in HKEY_CLASSES_ROOT\CLSID, and then writes all the names of subkeys to an XML file for reference.
It's pretty simple stuff, really. This registry location stores configuration information for all the registered COM classes on my machine, and there are about 4.000 subkeys.
Each subkeys Name is the hexadecimal string representation of a 128-bit number known as a Globally Unique Identifier (GUID). When represented textually, GUIDs are always displayed in the following canonical form:
BDA4A270-A1B1-11D0-8C2C-0080C73925BA
The HKEY_CLASSES_ROOT\CLSID subkeys are named exactly like this, except that they begin and end with curly braces.
I enumerate the subkeys with a simple for loop, saving the GUID to a TCHAR buffer (size, 128 bytes) and everyting works OK, until I hit a subkey about a third of the way down that is a GUID with one of the integers missing. Then the RegEnumKeyEx function stops writing the GUIDs to the TCHAR buffer, but continues on without generating an error code.
The program code then writes the GUID text strings to my XML file (this part works great).
I had to write another function that uses RegEnumKeyEx in a for loop again, but indexes the enumeration to begin at the subkey immediately after the truncated GUID that caused the problem initially, and runs to the final key (total subkey count obtained with RegQueryInfoKey). This works successfully. but the entire process of the determining the source of the error, and writing a seperate enumeration function was quite time consuming (I initially thought it was insufficient memory.).
I'm wondering if anyone knows why RegEnumKeyEx behaves like this. Surely, it doesn't check the text GUID values for validity. I used Registry Editor to search for other keys and associated values for that one malformed GUID, and found about a dozen entries, all with the same exact truncated format (weirdly enough, it's a Visual Studio component!).
Any useful comments are appreciated,...thanks.
|
|
|
|
|
Baltoro wrote: I enumerate the subkeys with a simple for loop...
What does this loop look like? Something like:
if (RegOpenKeyEx(HKEY_CLASSES_ROOT, "CLSID", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
while (! bDone)
{
dwSize = 128;
lResult = RegEnumKeyEx(hKey, dwIndex, szBuffer, &dwSize, NULL, NULL, NULL, &fileTime);
if (lResult == ERROR_MORE_DATA || lResult == ERROR_SUCCESS)
{
cout << szBuffer << endl;
dwIndex++;
}
else
bDone = TRUE;
}
RegCloseKey(hKey);
}
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
The for loop that enumerates the HKEY_CLASSES_ROOT\CLSID key is as follows:
DWORD dwRetVal = 0 ;
for (DWORD dwClsidIndx = 1 ; dwClsidIndx <= 1488 ; dwClsidIndx++)
{
TCHAR ComClssGuid [128] ;
ZeroMemory (&ComClssGuid, 128) ;
LPTSTR pComClsid = ComClssGuid ;
dwRetVal = RegEnumKeyEx (hRootKey, dwClsidIndx, ComClssGuid, &dwSize, NULL, NULL, NULL, &ftLastWrtTime) ;
if ((dwRetVal != ERROR_SUCCESS) && (dwRetVal != ERROR_MORE_DATA))
{
dwRetErrorVal = dwRetVal ;
dwErrNumClsid = dwClsidIndx ;
dwClsidErrors++ ;
TCHAR ErrorMessage [192] ;
wsprintf (ErrorMessage, TEXT(" ERROR: Number of Errors: %lu. ERROR: CLSID %lu. Error Code: %lu"), dwClsidErrors, dwErrNumClsid, dwRetErrorVal) ;
SetStatusMessage (ErrorMessage) ;
return FALSE ;
}
WriteClsidNodesAlpha (ClsidDomDoc, pDocRtElment, pComClsid, dwClsidIndx) ;
}
Explanation: dwRetErrorVal, dwErrNumClsid, and dwClsidErrors, are all DWORD variables declared outside of the function, used just to store the error code, CLSID subkey number, and the total number of such errors.
WriteClsidNodesAlpha is the function that writes the data to a Node in an XML file.
...and SetStatusMessage merely displays text in the application's status bar.
|
|
|
|
|
David Crow,
Sorry, I can't get at the edit control to change the last post. You're probably laughing, it's such a ridiculous post. You will notice that the test expression in the for loop is: dwClsidIndx <= 1488
Well, I changed that value after the loop initially failed (at CLSID number 1488). it originally was 3965 (which is the value returned from RegQueryInfoKey, dwNumSubKeys).
You will also notice that I begin the enumeration at value 1, instead of zero, as recommended by the documentation. This is because, I was getting the same name "CLSID" written to the TCHAR ComClssGuid [128] buffer, 3965 times (each time the loop executed).
The code just preceeding the loop, where I obtain the hKey value is here:
DWORD dwNumBubKeys = 0 ;
DWORD dwMaxSubLen = 0 ;
DWORD dwSize = 128 ;
FILETIME ftLastWrtTime ;
HKEY hRootKey = NULL ;
const TCHAR ComClsidEntrs [] = TEXT("CLSID") ;
LPCTSTR ClsidKeys = ComClsidEntrs ;
RegOpenKeyEx (HKEY_CLASSES_ROOT, ClsidKeys, 0, KEY_ALL_ACCESS, &hRootKey) ;
RegQueryInfoKey (hRootKey, NULL, NULL, NULL, &dwNumBubKeys, &dwMaxSubLen, NULL, NULL, NULL, NULL, NULL, NULL) ;
DWORD dwRetVal = 0 ;
for (DWORD dwClsidIndx = 1 ; dwClsidIndx <= 3965 ; dwClsidIndx++)
{
TCHAR ComClssGuid [128] ;
ZeroMemory (&ComClssGuid, 128) ;
LPTSTR pComClsid = ComClssGuid ;
dwRetVal = RegEnumKeyEx (hRootKey, dwClsidIndx, ComClssGuid, &dwSize, NULL, NULL, NULL, &ftLastWrtTime) ;
if ((dwRetVal != ERROR_SUCCESS) && (dwRetVal != ERROR_MORE_DATA))
{
dwRetErrorVal = dwRetVal ;
dwErrNumClsid = dwClsidIndx ;
dwClsidErrors++ ;
TCHAR ErrorMessage [192] ;
wsprintf (ErrorMessage, TEXT(" ERROR: Number of Errors: %lu. ERROR: CLSID %lu. Error Code: %lu"), dwClsidErrors, dwErrNumClsid, dwRetErrorVal) ;
SetStatusMessage (ErrorMessage) ;
return FALSE ;
}
WriteClsidNodesAlpha (ClsidDomDoc, pDocRtElment, pComClsid, dwClsidIndx) ;
}
Really, it's more of an annoyance than anything, since I was able to correct the problem. I'm just curious as to why it happened.
|
|
|
|
|
Thanks, Davis Crow,
You know, it's probably something internal,...something that I can't access programmatically.
Don't worry about it. Maybe even it's corruption in the registry storage copy. My machine is old (running Windows XP, SP1).
Now, I know how to keep my code blocks from causing the displayed text to run off the page (here in the forum). Unfortunately, I can't even delete the post and repair the version. I know it looks confusing.
|
|
|
|
|
Baltoro wrote: Unfortunately, I can't even...repair the version. I know it looks confusing.
Actually you can. Go to one of your other posts and click the Edit button. Change the number in the URL to 2983307.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Baltoro wrote:
for (DWORD dwClsidIndx = 1 ; dwClsidIndx <= 1488 ; dwClsidIndx++)
{
TCHAR ComClssGuid [128] ;
ZeroMemory (&ComClssGuid, 128) ;
LPTSTR pComClsid = ComClssGuid ;
dwRetVal = RegEnumKeyEx (hRootKey, dwClsidIndx, ComClssGuid, &dwSize, NULL, NULL, NULL, &ftLastWrtTime) ;
The problem is most likely that the dwSize variable is changed every time you call RegEnumKeyEx. Since most of the keys returned have 128 characters, you're ok. However the key with the missing digit causes dwSize to be set to 127, so from that point on, the value is too small to hold the rest of the keys.
The solution is to simply set dwSize to 128 at at the top of your for loop.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
krmed,
That was it, EXACTLY! Thanks to both you and David Crow, I appreciate it.
I'm SO embarrassed! I can't believe that I made such an idiotic mistake.
Anyway, thanks again.
modified on Saturday, March 28, 2009 5:19 PM
|
|
|
|
|
How do I add event handler for dynamically created controls in MFC? For example a button & an onclick event.
|
|
|
|
|
grassrootkit wrote: How do I add event handler for dynamically created controls in MFC? For example a button & an onclick event.
Just like any other button click:
BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
ON_BN_CLICKED(IDC_SOME_BUTTON, OnButtonClicked)
END_MESSAGE_MAP()
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Can't follow you. I'm creating the control like:
CButton* pButton = new CButton;
pButton->Create("&ENTER", WS_CHILD | WS_VISIBLE,
CRect(0, 0, 100, 43), this, 1);
How do I assign a handler for this? I do not even know it's ID here. Little unclear.
|
|
|
|
|
grassrootkit wrote: I do not even know it's ID here.
Have you bothered to read the documentation? The fifth argument is the ID.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
DavidCrow wrote: Have you bothered to read the documentation? The fifth argument is the ID.
. Please excuse. That's dumb. Thanks for the reply.
|
|
|
|
|
Will that be enough, or is another shoe to drop?
|
|
|
|
|
I'm missing the punch line, Mike.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Not really one. I was predicting this[^] it hadn't shown up before I posted mine.
Looking at the times it no longer reflects the predictive nature of my post.
|
|
|
|
|
You need to define a hard-coded range of IDs for your dynamically created controls.
for example, you can decide that the range
#define IDC_DYNAMIC_CONTROL_RANGE_START 1300
#define IDC_DYNAMIC_CONTROL_RANGE_START 2000
And when you create a new control, you assign the first free ID in the range; that means you will have
a limit on how many controls you will be able to support.
This signature was proudly tested on animals.
|
|
|
|
|
Here is my code:
void CtimerDlg::OnTimer(UINT_PTR nIDEvent)
{
CString prazno;
prazno="";
progres.SetPos(100);
int j= (rand()%2)+1;
if(j==1)
{
m_sEdit=getRandomSymbol1();
AppendTextToEditCtrl(m_edit, m_sEdit);
skritEdit.GetWindowText(strGet);
strGet.MakeUpper();
}
else
{
m_number=getRandomSymbol2();
char c[10];
_itoa(m_number,c,10);
MFCString=c;
AppendTextToEditCtrl(m_edit, MFCString);
skritEdit.GetWindowText(strGetN);
}
if(m_sEdit==strGet) stevec1=stevec1+1;
else stevec2=stevec2+2;
if(MFCString==strGetN) stevec1=stevec1+1;
else stevec2=stevec2+2;
m_sEdit="";
strGet="";
m_number=0;
MFCString="";
strGetN="";
skritEdit.SetWindowTextW(prazno);
UpdateData(FALSE);
progres.SetPos(0);
CDialog::OnTimer(nIDEvent);
}
NOTE* skritEdit is CEdit with focuson and hidden where user is typing chars and numbers from keyboard. m_edit is also CEdit but visible where random chars and number are shown.
NOTE2* GetRandomSymbol1 returns char, GetRandomSymbol2 returns int.
And here are buttons that starttime and killtime..
void CtimerDlg::OnBnClickedButton2()
{
CString prazno2;
prazno2="";
this->KillTimer(1);
char e[10];
itoa(stevec1,e,10);
CString proba;
proba=e;
m_edit.SetWindowTextW(prazno2);
MessageBox(proba);
stevec1=0;
}
void CtimerDlg::OnBnClickedButton3()
{
this->SetTimer(1,x,0);
skritEdit.SetFocus();
slider.EnableWindow(FALSE);
}
Can you tell me why stevec1 and stevec2 aren't counting correctly.. in function ontimer there is MFCString always empty..like conversion with itoa wouldn't work..
|
|
|
|
|
Aljaz111 wrote: this->SetTimer(1,x,0);
What is the value of x ? In practice, it has a minimum value of about 15 .
Aljaz111 wrote: Can you tell me why stevec1 and stevec2 aren't counting correctly.. in function ontimer there is MFCString always empty..like conversion with itoa wouldn't work..
Have you used the debugger to step through the code to see what is going on? Much, much easier than looking at a big wad of code and wondering what could be wrong.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
value of x comes from onsliderrelease...i have slider.setrange(0,1000).. x=slider.getpos(); in function on slider released..
I used debugger..when it comes to MFCString it is always empty.. more..this button which kills ontimer shows wrong stevec1 or stevec2.. With debuger i saw that sometimes stevec1 goes +1 when numbers are randomly shown..with or without comparison for numbers--> if(MFCString==..).. When i used debuger only for chars..stevec1 is counting correctly but onbutton for killing time..stevec is wrong..as i said before..if numbers are shown sometimes stevec1 just goes +1 ...
|
|
|
|
|
hello all,
LPTSTR lptSub = ( LPTSTR ) malloc ( sizeof(LPTSTR)* 25 );
LPTSTR lptMessage = (LPTSTR) malloc ( sizeof(LPTSTR) * 256 );
_tcscat( lptMessage, lptSub );
is it fine....??
|
|
|
|
|