Nested class with pinvoke in generic class

No idea why this limitation exists, but apparently it is not possible to call pinvoke methods in a nested class from a method in a generic class.

 I had something like this:

public class Foo
{
    private class FooGeneric
    {
        private HandleRef handle;
        private const uint SOMEMSG;

        private void DoSomething()
        {
            NativeMethods.SendMessage(handle, SOMEMSG, IntPtr.Zero, IntPtr.Zero);
        }
        
        private static class NativeMethods
        {
            [DllImport(“user32.dll”, CharSet = CharSet.Auto)]
            public static extern IntPtr SendMessage(HandleRef hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
        }      
    }
}

Just before DoSomething was called in my code I got a TypeLoadException with the message:

Generic method or method in generic class is internal call, PInvoke, or is defined in a COM Import class.

Solved it by moving the NativeMethods class outside of the generic class.

Custom file name separator for Windows Media Player

After a failed attempt at finding out how to use a custom file name separator using google I located the registry value where Windows Media Player stores the separator using RegMon. So simple I really should’ve tried that first 🙂

HKEY_CURRENT_USER\Software\Microsoft\MediaPlayer\
Preferences\CDRecordFileSeparator

I’ve only tried setting the value to ‘ – ‘ which works just fine, but any other string probably works too.  

Google talk themes and non-admin accounts

Today I go the new, 1.0.0.92, version of Google Talk. There are a few new features, avatar images and chat window themes. Looks really neat.
Unfortunately it does not work 100% with non-admin accounts. Only the classic chat window theme is available. Not sure what goes wrong, it has happened on all my computers, but at least there is a simple fix.

Find the google talk settings directory on the administrator account used to install google talk, when logged in with that account.The “local settings” part is localized, so for a swedish OS it is “lokala inställningar” instead.

c:\document and settings\username\local settings\application data\google\google talk

Then copy the themes directory to the same location for any non-admin accounts and change the permissions on the directory to match the parent directory. And that’s it.

StarForce is great

Helped a friend today who had some trouble with his computer. Whenever one interacted with “My computer”, right clicking or viewing didn’t matter, the computer completely froze for a few minutes. After I had looked through the list of running processes not finding anything really suspicious I checked on a hunch if he had the StarForce drivers installed. They were installed, so I used the StarForce Cleaner Utility to remove it. And to my surprise, or maybe not, all his troubles went away. Or at least, the computer stopped freezing every now and then.

Switching to PAL-60 wasn’t very difficult after all

I thought that I had to get some other output from the Xbox 360 to my TV to be able to set it to non-hdtv out. But it was just a small switch on the cord I was already using.

So now that I’ve switched to non-hdtv, changed to PAL-60, and then switched the cord back to hdtv out I can try all the new demos I previously complained that I couldn’t test. AstroPop seems like fun, but I’m not so sure if Feeding Frenzy can capture my attention for very long. Especially now that I’m planning on buying Oblivion tomorrow. Can’t wait to try it 😀

Still somewhat annoyed though that I had to change to PAL-60 when that setting isn’t used at all when using a hdtv.

Crappy code now available on Live Arcade!

Wanted to try the The Outfit demo and the Feeding Frenzy demo but ran into a little problem. These two Xbox 360 games only work using PAL-60 when using the standard definition output, so if the Xbox 360 is set to PAL-50 the two games refuse to start. When using the high definition output, as I am, the Xbox detects this and do not allow changing from PAL-50 to PAL-60. So it looks like I wont be able to try these two games for now. Don’t know if it is an error in the Xbox 360 or these two games, but I hope it is fixed soon!

Looks like I’m not the only one using the high definition output, schrankmonster wrote about exactly the same issue a few days ago.

Update: The new game AstroPop has the same annoying problem.

A brand new phone

This monday I finally got a brand new SE k750i. Hurray! Hopefully this one will not break as the previous one did.

First I waited until after the date I got in a letter from OnOff that said that servicing my phone would take longer than expected. Then when nothing happened I called OnOff’s phone support and they said that the service partner was waiting for a replacement part so they could fix the old phone. This got me a little bit worried so I went to the OnOff store where I left my phone for replacement. You see, you can’t call the store directly, and the central phone support apparently does not know anything.

The salesman at the store, who seemed to really want to help me, contacted the service partner and they said that they were not trying to repair the phone as OnOff phone support had claimed, instead they were doing nothing at all. So the OnOff salesman got me a new phone from the store and a 200 SEK giftcertificate since he thought it had taken to long. Couldn’t agree with him more. Too bad they couldn’t just have given me a new phone the first time when I left my broken phone with them. OnOff or Sony-Ericsson, don’t know which, had already approved that I was going to get a new phone instead of them trying to repair the old phone once more.

Fixing “LUA bugs” article

Fixing “LUA bugs”, Part I by Aaron Margosis, an interesting read about how to handle applications that needs an administrator account to run even though they really shouldn’t need it.

The first, and best, solution is to let the applications developer fix it. Although it sounds great on paper, right now it seems really hard to convince some developers to make sure their applications run as a non-admin user. At least that is what I found out when I contacted Sony-Ericsson. But game developers are probably the worst when it comes to making their games run as non-admin. If their plan has been all along to make me stop playing PC games and move over to playing only on my Xbox they’ve succeeded.

Link