1
2 //---------------------------------------------------------------------------
3
4 #include <vcl.h>
5 #pragma hdrstop
6
7 #include "Unit1.h"
8 //---------------------------------------------------------------------------
9 #pragma package(smart_init)
10 #pragma resource "*.dfm"
11 TForm1 *Form1;
12 //---------------------------------------------------------------------------
13 __fastcall TForm1::TForm1(TComponent* Owner)
14 : TForm(Owner)
15 {
16 }
17 //---------------------------------------------------------------------------
18
19
20 void __fastcall TForm1::Button1Click(TObject *Sender)
21 {
22 STARTUPINFO si;
23 ZeroMemory(&si,sizeof(STARTUPINFO));
24 si.cb = sizeof(STARTUPINFO);
25 PROCESS_INFORMATION pi;
26
27 //enter the name and file path of the ocx to register
28 if (CreateProcess(NULL,"C:\\Windows\\System\\Regsvr32.exe unknown.ocx",
29 NULL,NULL, false,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi)){
30 CloseHandle(pi.hThread);
31 WaitForSingleObject(pi.hProcess,INFINITE);
32 CloseHandle(pi.hProcess);
33
34 return;
35 }
36 else
37 {
38 MessageDlg("unknown.ocx not found!", mtInformation, TMsgDlgButtons() << mbYes,
39 0);
40 return;
41 }
42
43
44 }
45 //---------------------------------------------------------------------------
|