Welcome to differentpla.net, where Roger occasionally posts snippets of code and other stuff that he feels like sharing with the world.
roger's picture

Adding an extra (optional) page to the C# Wizard

This seems to be causing a few problems, so I'll quickly walk through it. I'll try to throw some screenshots in later.

In the TestWizard project, choose "Add New Item". In the dialog, choose "Inherited User Control" (it's under Windows Forms). Call it OptionalPage.cs. The Inheritance Picker will appear. Choose "InternalWizardPage".

In the forms designer, click on the banner and change the Title and Subtitle properties to "Optional Page" and "This page is optional".

In the constructor for TestWizardSheet, add a line to add the OptionalPage:

roger's picture

Things I learnt this week: RegSvr32.EXE on Windows x64

On Windows, 64-bit processes cannot load 32-bit DLLs, and 32-bit processes cannot load 64-bit DLLs. How does REGSVR32.EXE manage to successfully register both 32-bit and 64-bit COM DLLs?

roger's picture

Things I learnt this week: SetWaitableTimer

SetWaitableTimer doesn't accept NULL for the pDueTime parameter. It returns FALSE; GetLastError() returns ERROR_NOACCESS (998). If you specify zero (i.e. a LARGE_INTEGER containing zero) for pDueTime, the timer is signalled immediately.

There are 10,000,000 FILETIME units (100ns) in a second. There are 10,000 FILETIME units (100ns) in a millisecond. Something like this might come in useful:

roger's picture

Things I learnt this week: SVCHOST

SVCHOST services are configured by having ImagePath set to "%windir%\system32\svchost.exe -k name-of-service", and a Parameters key containing ServiceDll (REG_EXPAND_SZ), which names a DLL with a ServiceMain entry point. ServiceMain has argc and argv.

roger's picture

Things I learnt this week: RegQueryValueEx

RegQueryValueEx, when passed lpData = NULL, will set *lpcbData to the length required in bytes, even if it's already set to something. If lpData != NULL, and *lpcbData is too short, RegQueryValueEx will return ERROR_MORE_DATA.

This means that you probably ought to call it in a loop, like this:

roger's picture

Things I learnt this week: RegSetValueEx

RegSetValueEx, when passed REG_SZ, needs the length to be in bytes, so don't just use _tcslen like this:

    TCHAR sz[] = _T("Hello World");
    RegSetValueEx(hKey, bstrValueName, 0, REG_SZ, (const BYTE *)sz, _tcslen(sz));

That truncates the value placed in the registry (11 bytes where it actually needed 24, including the null terminator).


RegSetValueEx, when passed REG_SZ, is documented as needing the length to include the NULL terminator.

roger's picture

Generating SSL certificates for differentpla.net

Because I keep forgetting how to.

roger's picture

empeg tools

In response to this thread on the empeg BBS, I hacked together a couple of small tools for the empeg car player.

roger's picture

Odd behaviour with WCF base addresses and HTTP.SYS wildcards

I'm at DevWeek this week, and I went (among other things) to a couple of WCF presentations by Aaron Skonnard.

So, anyway, last night I put together a really simple WCF service. It looks like this:

Syndicate content