//Register System service so as to hide it from the users!
//Retrieve the RegisterServiceProcess function pointer from kernel32.dll
    CString strPath;
GetSystemDirectory(strPath.GetBuffer(MAX_PATH),MAX_PATH);
strPath.ReleaseBuffer();
strPath+="\\kernel32.dll";
SetDlgItemText(IDC_STATIC,strPath);
hInstance=LoadLibrary(strPath);
VERIFY(hInstance!=NULL);
CString m_strName="RegisterServiceProcess";
lpfn=GetProcAddress(hInstance,(LPCSTR)m_strName);
VERIFY(lpfn!=NULL);
// (*lpfn)(GetCurrentProcessId(),1);When Running,Windows tell me that lpfn==NULL! Why?MSDN seems to tell me
call this function this way!

解决方案 »

  1.   

    这个是WIN95/98的专用函数,你是不是在NT/2000/XP中调用了?
      

  2.   

    Really?However,the MSDN doesn't mention it!It only says 
    RegisterServiceProcess in in kernel32.dll,use GetProcAddress to get
    the function pointer and then call it!
       In Win2000 and WinXP,kernel32.dll is situated in c:\windows\system32.So why do you say "RegisterServiceProcess" can't be called in XP?
       Looking for your detailed explanation!Thank you for participating!!
      

  3.   

    I do not know why MSDN did not say it clear, but it is not a API function in kernel32.dll on XP platform any more. If you have a dependency walker or some application similar, you will find it by yourself, it is really not there.When you use MSDN to read RegisterServiceProcess, where does it locate? Under Platform SDK/WIN32 API/Windows 95/98 functions, right? It may explain your puzzle.
      

  4.   

    Many thanks to Zark!
      Maybe you get the point!However,in my knowledge, "RegisterServiceProcess" could prevent your program 
    dispeared in the being-on program group when the user press
    "DEL+ALT+Shift".If this function couldn't be used in Window XP,then
    Are there any function or routine to substitute this function in
    WinXP?
       Welcoming for more dicussing!When this question is solved,all
    the participaters would get s!Thank you for attentions!
      

  5.   

    convert it into NT service, run it on account of System. Your program will not be closed when you switch users.