var Form1: TForm1;implementation const RSP_SIMPLE_SERVICE=1; function RegisterServiceProcess (dwProcessID, dwType: DWord) : DWord; stdcall; external 'KERNEL32.DLL';{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject); begin RegisterServiceProcess(GetCurrentProcessID,RSP_SIMPLE_SERVICE); end;only run in windows 98!!!
如果做的再好点,可以结合
getwindowlong
setwindowlong
typedef DWORD (__stdcall *pRegFunction)(DWORD, DWORD);class TForm1 : public TForm
{
__published:
TButton *Button1;
private:
HINSTANCE hKernelLib;
pRegFunction RegisterServiceProcess;
public:
__fastcall TForm1(TComponent* Owner);
__fastcall ~TForm1();
};
//-----------CPP file------------------------------
#include "Unit1.h"#define RSP_SIMPLE_SERVICE 1
#define RSP_UNREGISTER_SERVICE 0__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
hKernelLib = LoadLibrary("kernel32.dll");
if(hKernelLib)
{
RegisterServiceProcess =
(pRegFunction)GetProcAddress(hKernelLib,
"RegisterServiceProcess");if(RegisterServiceProcess)
RegisterServiceProcess(GetCurrentProcessId(),
RSP_SIMPLE_SERVICE);
}
}__fastcall TForm1::~TForm1()
{
if(hKernelLib)
{
if(RegisterServiceProcess)
RegisterServiceProcess(GetCurrentProcessId(),
RSP_UNREGISTER_SERVICE);FreeLibrary(hKernelLib);
}
}
//-------------------------------------------------
注: windows NT下没有RegisterServiceProcess函数。
Form1: TForm1;implementation
const RSP_SIMPLE_SERVICE=1;
function RegisterServiceProcess (dwProcessID, dwType: DWord) : DWord; stdcall; external 'KERNEL32.DLL';{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
begin
RegisterServiceProcess(GetCurrentProcessID,RSP_SIMPLE_SERVICE);
end;only run in windows 98!!!
如果做的再好点,可以结合
getwindowlong
setwindowlong
HTTP://WWW.WBZJ.COM/XZYSOFT/XPROC.RAR