hschumann2/TempleOS-Source-Code
0847
1 2#help_index "Registry/Install Registration"3 4public CInsReg ins_reg;5MemSet(&ins_reg,0,sizeof(CInsReg));6 7DefineLstLoad("ST_HOST_OSES","Other\0Native\0Linux\0Windows\0");8DefineLstLoad("ST_HOST_VMS","Other\0Native\0VMware\0QEMU\0VirtualBox\0");9 10#define RR_UNREGISTER -111#define RR_REGISTER 012#define RR_REREGISTER 113 14public Bool InsReg(U8 drv_let=0,I64 action=RR_REGISTER)15{//Register this install in local Registry.HC file.16 CInsReg r;17 I64 old_drv_let;18 Bool res=FALSE;19 20 if (action==RR_UNREGISTER) {21 MemSet(&r,0,sizeof(CInsReg));22 res=TRUE;23 } else if (action==RR_REREGISTER || !ins_reg.registered) {24 MemCpy(&r,&ins_reg,sizeof(CInsReg));25 r.registered=TRUE;26 if (PopUpForm(&r))27 res=TRUE;28 }29 30 if (res) {31 old_drv_let=*sys_registry_doc->filename.name;32 if (drv_let)33 *sys_registry_doc->filename.name=drv_let;34 RegWrite("Adam/InsReg",35 "#help_index \"Registry/Install Registration\"\n"36 "MemSet(&ins_reg,0,sizeof(CInsReg));\n"37 "ins_reg.registered=%d;\n"38 "ins_reg.host_os=%d;\n"39 "ins_reg.host_vm=%d;\n"40 "\n#define INS_REG_PERSONAL_INITIALS \"%s\"\n"41 "StrCpy(ins_reg.initials,\"%s\");\n"42 "HashPublic(\"INS_REG_PERSONAL_INITIALS\",HTT_DEFINE_STR);\n"43 "\n#define INS_REG_MACHINE_NUM %d\n"44 "ins_reg.machine_num=%d;\n"45 "HashPublic(\"INS_REG_MACHINE_NUM\",HTT_DEFINE_STR);\n"46 "\n\"InsReg:%%s:%%d\\n\","47 "INS_REG_PERSONAL_INITIALS,INS_REG_MACHINE_NUM;\n"48 "\n#help_index \"\"\n"49 ,r.registered,r.host_os,r.host_vm,50 r.initials,r.initials,r.machine_num,r.machine_num);51 *sys_registry_doc->filename.name=old_drv_let;52 RegExe("Adam/InsReg");53 }54 return res;55}56 57public Bool InsRereg(U8 drv_let=0)58{//Reregister this install in local Registry.HC file.59 return InsReg(drv_let,RR_REREGISTER);60}61 62public Bool InsUnreg(U8 drv_let=0)63{//Unregister this install in local Registry.HC file.64 return InsReg(drv_let,RR_UNREGISTER);65}66 