May 4th, 2012
It sounds pretty straightforward to enumerate the resources in a file. But it turned out to be rather a lot of work (and waste of time), since the MS doesn’t tell you, that it doesn’t enumerate the strings, but blocks of strings in a binary format that you have to process yourself.
Here’s how to do it:
BOOL CALLBACK EnumResNameProc(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam)
{
switch ((int)lpszType)
{
case RT_STRING:
{
HRSRC hRes = FindResourceEx(hModule, RT_STRING, MAKEINTRESOURCE(lpszName), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL));
if (hRes)
{
HGLOBAL hGlo = LoadResource(hModule, hRes);
LPCWSTR lpStr = (LPCWSTR)LockResource(hGlo);
DWORD dwsize = SizeofResource(hModule, hRes);
long count=0;
for (int i=0; i < (int)dwsize; i++)
{
count++;
if (count>=16)
break;
if (lpStr[i])
{
WORD *pString = lpStr+i+1;
long lString = lpStr[i];
//Process string here
i += lpStr[i];
}
}
}
}
break;
}
return(TRUE);
}
EnumResourceNames(hModule, RT_STRING, &EnumResNameProc, NULL);
Tags: EnumResourceNames, resources, RT_STRING
Posted in C++, programming | No Comments »
April 1st, 2012
It sounds like an April Fools’ Day prank. But I didn’t make this one up. Promise.
I just entered “iTunes” as search keyword for Google AdWords. I wasn’t surprised that Google didn’t allow it. But it reason was a jaw-dropper:
These entries could not be added due to the following reasons:
Unacceptable Business Practices (Detail)
We’ve detected that your keyword list may contain words related to unacceptable business practices. Google policy does not permit the advertisement of websites that contain unacceptable business practices.
Recommended actions: Please delete or edit these keywords.
So is Google accusing Apple of ”Unacceptable Business Practices”? Sounds like it. I know that they didn’t really like each other since Google started Android, but this is pretty heavy stuff.
Screenshot:

Tags: apple google itunes
Posted in business | No Comments »
December 14th, 2011
1. The reason guesser
His goldfish died while the customer was installing your software. So it must be your fault. That’s why he sends you a three-page e-mail.
2. The ignorer
You wrote that the customer should do 1. … 2. … 3. … to solve the problem. The customer writes back that he did something completely different, that it still doesn’t work and that your support sucks.
3. The insister
Tells you that you’re all wrong, ignores everything that you wrote and insists that you’d better send him a solution RIGHT NOW.
And probably there are many more types…
Posted in humor | No Comments »
June 2nd, 2011
Just a tiny trick today.
When you’re programming, you’re often…
- typing something
- Then you browse through the same file, look for something
- copy something
- And now you want to get back to the place that you previously edited.
There’s a secret hotkey (actually a sequence) for that which works in most editors: Ctrl+Z, Ctrl+Y.
Works in Visual Studio, Word, text editors, etc.
Tags: back-to-edit, editing, hotkey, redo, undo
Posted in programming | No Comments »
April 5th, 2011
I recently published a new software: ZeroClickSpellchecker. It’s basically a spell-checker which doesn’t mark errors, but auto-corrects them. At least those that can be corrected safely. (It won’t try to correct kljfhsdakljh, for example.) But quite a lot errors can be corrected, so the program works pretty well. It effectively that speeds up your typing, because you don’t have to stop and correct any more.
It’s great tool when writing e-mails. Basically I wrote it because I was fed up with typing “copmuter” again and again. If you find this (or other typos) in your own e-mails, check out my auto-correction software.
Posted in business | No Comments »
March 21st, 2011
One of my favorite internal functions. It helps my manage my app’s GUI. Checkboxes that cause their sub-elements to be greyed out when not checked can be easily handled by this:
bool EnableWindowsDependingOn (CWnd *pParent, DWORD DependingOnThisCheckbox, DWORD Value1, ...)
{
va_list marker;
bool bState = (((CButton*)pParent->GetDlgItem(DependingOnThisCheckbox))->GetCheck()!=0);
DWORD i=Value1;
va_start (marker, Value1);
while (i != 0)
{
if (i<=0xffff)
{
if (pParent->GetDlgItem(i))
pParent->GetDlgItem(i)->EnableWindow (bState);
}
else
((CWnd*)i)->EnableWindow (bState);
i = va_arg (marker, long);
}
va_end (marker);
return (bState);
}
It excepts the this pointer of your CDialog and the id of the master checkbox. Then you can append any number of sub-element ids or pointers. And finally a NULL. Example:
EnableWindowsDependingOn (this, IDC_CHECK1, IDC_EDIT1, IDC_EDIT2, NULL);
This would enable the two edit boxes if the checkbox is enabled.
Posted in C++, programming | No Comments »
December 31st, 2010
Placing a breakpoint can be dangerous. In some code sections, like drawing a menu, Windows doesn’t like to be interrupted. The debugger will stop your application, but your app will remain on-screen and Alt+Tab and all other options of changing the current application are blocked.
Except, if you’re using Windows 7.
For some reason the 3d-flipping mode with Win+Tab still works. And allows you to switch to the debugger.
Tags: debuggung, Windows, Windows 7
Posted in programming | No Comments »
December 7th, 2010
Step 1: Waste hours researching to find out how to do something trivial. (Like renaming the insert link)
Step 2: Curse Microsoft
Step 3: Throw out the MS way and program it yourself.
Repeat for every trivial issue.
Tags: rant
Posted in microsoft, programming | No Comments »
November 24th, 2010
…of the order form. I always suspected it, but it’s interesting to be on the other side for a change.
I’m talking about being a customer for a change. I tried to check out AISIP’s member forums and one has to pay for that. Okay, I tried. I filled in the reg.net order form, hit the submit button only to see the same form again. I double-checked my data, I looked for marks that I forget something. Nothing. Same form again. I triple-checked my data, tried another browser, another computer. Even my iPhone. Nothing worked. I contacted AISIP (three times). No reply. I contacted reg.net and got a standard mail. My reply to that mail was left unanswered.
So I want to pay, but I can’t. It’s frustrating.
Hope you’re treating your customers better than that. I know that I do, but I wonder if I should test *my* payment processor…
Tags: AISIP, reg.net
Posted in business | No Comments »
October 19th, 2010
There’s a hidden switch in Visual Studio 2005 while doubles compile speed.
I know, it sounds ridiculous. But I’ve tested it. It’s MUCH faster now. The switch works by enabling multi-core processing. I have no idea why Microsoft has hidden this, instead of making it a big, obvious feature.
Anyways. You can enable it by adding /MP to the “Additional options” in “Configuration properties > C/C++ > Commandline”.
(Found it at 1 and 2)
Posted in C++, microsoft, programming | No Comments »