别人的原码和执行程序。
程序是先注册到win2000系统里的,然后由系统服务启动。
我不知道如何调试。因为按F5调试相当于直接执行程序,而不是由系统服务启动。
谢谢大家帮忙。
程序是先注册到win2000系统里的,然后由系统服务启动。
我不知道如何调试。因为按F5调试相当于直接执行程序,而不是由系统服务启动。
谢谢大家帮忙。
解决方案 »
- VC++界面
- 给位大侠,测试服务程序性能,都用什么工具来着
- 请教一个进制转换问题
- 两个用户用ADO同时读取修改SQL同一个表同一条记录时出错,请问是不是要修改连接参数??
- 如何做一个更换位图的功能?急!
- Rut-Time Check Failure #2- Stack around the variable 'sSubMsg' was corrupted.
- 在创建FRAME窗口的时候,如何显示或隐藏标题栏
- 简单问题
- 关于Win2000的问题,有兴趣,就来看!
- masterz()以前写的一个程序,我苯看不懂,谁帮帮我?
- 重分求购!!!
- 文件读写操作问题,请高手大侠帮忙!!谢谢!!问题解决,300分
1.command line in system menu run:
msdev -p your service's processid.
2.debug from taskmanager:
select your process,right click,and select debug option.
#ifdef _X86_
#define DEBUGBREAK() _asm { int 3 }
#endifBOOL ChangeServiceDesktop(void)
{
HDESK hdeskCurrent;
HDESK hdesk;
HWINSTA hwinstaCurrent;
HWINSTA hwinsta; //
// Save the current Window station
//
hwinstaCurrent = GetProcessWindowStation();
if (hwinstaCurrent == NULL)
return FALSE; //
// Save the current desktop
//
hdeskCurrent = GetThreadDesktop(GetCurrentThreadId());
if (hdeskCurrent == NULL)
return FALSE; //
// Obtain a handle to WinSta0 - service must be running
// in the LocalSystem account
//
hwinsta = OpenWindowStation(_T("winsta0"), FALSE,
WINSTA_ACCESSCLIPBOARD |
WINSTA_ACCESSGLOBALATOMS |
WINSTA_CREATEDESKTOP |
WINSTA_ENUMDESKTOPS |
WINSTA_ENUMERATE |
WINSTA_EXITWINDOWS |
WINSTA_READATTRIBUTES |
WINSTA_READSCREEN |
WINSTA_WRITEATTRIBUTES);
if (hwinsta == NULL)
return FALSE; //
// Set the windowstation to be winsta0
//
if (!SetProcessWindowStation(hwinsta))
return FALSE; //
// Get the default desktop on winsta0
//
hdesk = OpenDesktop(_T("default"), 0, FALSE,
DESKTOP_CREATEMENU |
DESKTOP_CREATEWINDOW |
DESKTOP_ENUMERATE |
DESKTOP_HOOKCONTROL |
DESKTOP_JOURNALPLAYBACK |
DESKTOP_JOURNALRECORD |
DESKTOP_READOBJECTS |
DESKTOP_SWITCHDESKTOP |
DESKTOP_WRITEOBJECTS);
if (hdesk == NULL)
return FALSE;
// Set the desktop to be "default"
//
if (!SetThreadDesktop(hdesk))
return FALSE;
// Do a message box
//
/*
MessageBox(NULL, _T("MB_OK"), _T("test_interact"), MB_OK); //
// Reset the Window station and desktop
//
if (!SetProcessWindowStation(hwinstaCurrent))
return FALSE;
if (!SetThreadDesktop(hdeskCurrent))
return FALSE; //
// Close the windowstation and desktop handles
//
if (!CloseWindowStation(hwinsta))
return FALSE;
if (!CloseDesktop(hdesk))
return FALSE;
*/
return TRUE;
}在ServiceMain函数中调用ChangeServiceDesktop
然后设置断点,当执行到断点时会自动弹出调试对话框。
void WINAPI ServiceMain(DWORD dwArgc, PTSTR* pszArgv)
{
ChangeServiceDesktop();
DEBUGBREAK();
}