problem with bitblt/gdi functions in nt-service

just write whatever you want
Post Reply
cvarak
Posts: 2
Joined: Fri Feb 18, 2005 11:33 am

problem with bitblt/gdi functions in nt-service

Post by cvarak »

hi mad,

i used your hooking lib and found it great, well done, keep up the good work.

yet i have a problem having less to do with your lib, yet it's very lo-level.
so, when i try to capture desktop screen with something like:

Code: Select all

myDIB:=TFastDIB.Create;

  hdcScreen := GetDC(GetDesktopWindow); //CreateDC('DISPLAY', nil, nil, nil);
  hdcCompatible := CreateCompatibleDC(hdcScreen);

  myDIB.SetSize(GetDeviceCaps(hdcScreen, HORZRES),GetDeviceCaps(hdcScreen, VERTRES),  GetDeviceCaps(hdcScreen, BITSPIXEL));

  SelectObject(hdcCompatible, myDIB.Handle);

  BitBlt(hdcCompatible,
    0, 0,
    myDIB.Width, myDIB.Height,
    hdcScreen,
    0, 0,
    SRCCOPY);

  myDIB.SaveToFile(...);
  ..
  [freeing]

it works as a standalone. yet, when i try the same thing from a nt-service, the result is a black image :o

do you have any idea/solution for this issue?
can it be that gdi is not loaded at service-init time?

lg,
cvarak
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Services run in their own desktop, I believe. I've not too much knowledge in this area, though.
cvarak
Posts: 2
Joined: Fri Feb 18, 2005 11:33 am

Post by cvarak »

hi madschi,
habs gefunden. oops.

i found it - one simple flag is to be added to
in a CreateService call :
ServiceType => SERVICE_WIN32_OWN_PROCESS OR $100 {=SERVICE_INTERACTIVE_PROCESS}

and then it rocks. :wink:
Post Reply