Odd behavior in Windows Service status reporting from recent Windows 2008 R2

I have a Windows service program written many year ago and the user asked me to fix an issue that occurs recently in Windows 2008 R2. Indeed it is not a big problem but quite annoying. When the user stops the service, Windows always popup a window showing an error message like “Windows could not stop the […] service on local computer, The service did not return an error.” Damn it! How could you show me an error dialog with no error message?

Google doesn’t have any similar case like this. So I have try this and that, here and there.

OK, everybody knows that kind of experiments are boring and time consuming. So I just expose the answer.

In the service’s control handler codes for SERVICE_CONTROL_STOP, I reported a SERVICE_RUNNING status followed by a SERVICE_STOP status. That works without any problem before, but caused the issue in recent 2008 R2. After I changed the first status reporting to SERVICE_STOP_PENDING, the dialog disappears.

It looks like Windows doesn’t accept SERVICE_RUNNING when it sent to services SERVICE_CONTROL_STOP. But can you show me a clear error message?

 

Object subscripting in objc

Object scripting what use something other than an integer inside []. For example, dictionary[@”key”] = @”value”

And in generated machine code, it is a call to selector

-(id) objectForKeyedSubscripting:(id)key

An informal protocol named __ARCLiteKeyedSubscripting__ was defined

@protocol __ARCLiteKeyedSubscripting__
– (void)setObject:(id)arg1 forKeyedSubscript:(id)arg2;
– (id)objectForKeyedSubscript:(id)arg1;
@end

Built-in types like NSDictionary already implemented this protocol, which is indeed generated by compiler. For custom types, just implemented those 2 methods and everything will work.

Some license checkpoints in Reveal app.

  1. [IBAAppDelegate applicationDidFinishLaunching:] would call [IBAAppDelegate verifyCodeSignature] to verify code signature of the app to prevent itself from modifications.
  2. [IBATrialModeReminderPresenter shouldShowTrailModeSheet] controls whether trial mode sheet, including quit after trial period expired, would be shown.
  3. [IBAMainWindowController configureTitleBarAccesoryView] will create IBATrialModeReminderTitleBarAccessoryView to shown trial information on window’s title bar.

That’s all.

Make IB designed view work with iCarousel

Oddly, View designed in IB would have FlexibleWidth+FlexibleHeight set in it autoresizingMask, even if you cleared everything in auto resizing box, regardless using AutoLayout or not. The behavior causes that subviews inside item view have wrong positions after transform3D with rotations. In short, item view’s width/height in subviews position/constraints calculation would be calculated as rotated value instead of  preset value, 

The solution is put self.autoresizingMask = 0 to awakeFromNib, easiest? But it took me 1.5 days to find the reason.