G:/ScriptBasic/source/sbsetup/setup.c File Reference

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <shlobj.h>
#include <shellapi.h>
#include <commctrl.h>
#include <ole2.h>
#include <direct.h>
#include <sys/stat.h>
#include <process.h>
#include <zlib.h>
#include "../filesys.h"
#include "resource.h"
#include "examples.c"

Go to the source code of this file.

Data Structures

struct  linkinfo

Defines

#define VERSION_TEXT   "2.0.0"
#define MAJOR   2
#define MINOR   0
#define BUILD   0
#define KBNEEDED   8000
#define DEFAULT_PATH   "C:\\ScriptBasic\\"
#define INSTALL_HEADING   " Install ScriptBasic !"
#define REMOVE_HEADING   " Remove ScriptBasic !"
#define SOFT   "SOFTWARE\\"
#define LOCAL   HKEY_LOCAL_MACHINE
#define ROOT   HKEY_CLASSES_ROOT
#define SOFT   "SOFTWARE\\"
#define UNINSTALL   "SOFTWARE\\MICROSOFT\\WINDOWS\\CURRENTVERSION\\UNINSTALL\\"
#define GZFILE   "sbcab.bin"
#define INSTALL   1
#define REMOVE   2
#define RESET   1
#define NEXT   2
#define BASIC_NAME   "ScriptBasic"
#define BASIC_EXE   "scriba.exe"
#define BASIC_EXTENSION   ".sb"
#define BASIC_VERSION   "2.0"
#define BASIC_BUILD   "0"
#define BASIC_ICON   "scriba.ico"
#define BASDOC_ICON   "scribadoc.ico"
#define BASIC_README   "readme.txt"
#define BASIC_LICENSE   "copying.txt"
#define BASIC_SETUP   "setup.exe"
#define BASIC_LOG   "scriba.log"
#define DEFAULTFONT   "swiss13"
#define DEFAULTGEOMETRY   "+10+10"
#define MB_STYLE   MB_OK|MB_SYSTEMMODAL|MB_ICONINFORMATION
#define SSLEN   1024
#define INSTALL_CANCELLED   1
#define INSTALL_ABORTED   2
#define INSTALL_SUCCESS   3
#define INSTALL_FAILURE   4
#define REMOVE_SUCCESS   6
#define REMOVE_FAILURE   7
#define REMOVE_CANCELLED   8
#define SILENT   9
#define INSTALL_PARTIAL   10
#define MODUDOC(X, Y)   {CSIDL_PROGRAMS,BASIC_NAME"\\Documentation\\" X ".LNK", "mod_" Y ".chm","Link to mod_" X ".chm", "\027",FALSE,"DOC\\"},\

Typedefs

typedef linkinfo LINKINFO

Functions

void progress (char *msg)
char * app (char *trail)
int failReport (char *key, char *action)
static int DeleteRegistryKey (HKEY start, char *keyname, char *subkey)
char * GetSBRegString (char *name)
DWORD GetSBRegDW (char *name, DWORD *DW)
int PutRegistryKey (HKEY start, char *keyname, char *name, char *content)
int PutRegistryEKey (HKEY start, char *keyname, char *name, char *content)
int PutSBRegString (HKEY start, char *keyname, char *name, char *content)
int PutSBRegDW (HKEY start, char *keyname, char *name, DWORD DW)
char * GetRegistryKey (char *keyname, char *name)
int InstallQuestionYN (char *pszText)
char * brushup (char *path)
void brushupinline (char *path)
void logit (char *text)
int MyMessage (HWND handle, LPCSTR text, LPCSTR title, UINT style)
void end (int m)
UINT CALLBACK HookProc (HWND hdl, UINT msg, WPARAM wparam, LPARAM lparam)
BOOL CALLBACK pathdialog (HWND handle, UINT message, WPARAM wparam, LPARAM lparam)
void DeleteFromPath (char *Path)
void DeleteFromPathEx (char *Path, char *Ext)
int MyRegs (int mode)
BOOL CALLBACK progressdialog (HWND handle, UINT message, WPARAM wparam, LPARAM lparam)
void noprogress (char *msg)
HRESULT CreateShellLink (LINKINFO *li, char *path)
HRESULT DeleteShellLink (LINKINFO *li)
int MyLinks (int mode)
int MyFiles (int mode)
void InstallScriptBasic ()
void RemoveScriptBasic ()
int WINAPI WinMain (HINSTANCE _this_instance, HINSTANCE prev_instance, LPSTR commandline, int win_state)

Variables

int total_progress
int GlobalSuccessFlag = 1
char * pszInstallPath
HINSTANCE this_instance
char * temppath
char logs [10000]
int install
char * currentpath
int cancel
char string [SSLEN]
char logfilename [SSLEN]
int progress_wait
DWORD dwMajor
DWORD dwMinor
DWORD dwBuild
int timerid
MSG timermsg
RECT rc
static int count = 0
static HWND progressbox = NULL
static HWND hwndPB = NULL
char string [SSLEN]
int thumb


Define Documentation

#define BASDOC_ICON   "scribadoc.ico"
 

Definition at line 69 of file setup.c.

Referenced by MyLinks().

#define BASIC_BUILD   "0"
 

Definition at line 67 of file setup.c.

#define BASIC_EXE   "scriba.exe"
 

Definition at line 64 of file setup.c.

Referenced by MyRegs().

#define BASIC_EXTENSION   ".sb"
 

Definition at line 65 of file setup.c.

Referenced by MyRegs().

#define BASIC_ICON   "scriba.ico"
 

Definition at line 68 of file setup.c.

Referenced by MyLinks(), and MyRegs().

#define BASIC_LICENSE   "copying.txt"
 

Definition at line 71 of file setup.c.

#define BASIC_LOG   "scriba.log"
 

Definition at line 73 of file setup.c.

#define BASIC_NAME   "ScriptBasic"
 

Definition at line 63 of file setup.c.

Referenced by MyLinks(), and MyRegs().

#define BASIC_README   "readme.txt"
 

Definition at line 70 of file setup.c.

#define BASIC_SETUP   "setup.exe"
 

Definition at line 72 of file setup.c.

Referenced by MyRegs().

#define BASIC_VERSION   "2.0"
 

Definition at line 66 of file setup.c.

#define BUILD   0
 

Definition at line 35 of file setup.c.

Referenced by InstallScriptBasic(), MyRegs(), and RemoveScriptBasic().

#define DEFAULT_PATH   "C:\\ScriptBasic\\"
 

Definition at line 40 of file setup.c.

Referenced by InstallScriptBasic().

#define DEFAULTFONT   "swiss13"
 

Definition at line 75 of file setup.c.

#define DEFAULTGEOMETRY   "+10+10"
 

Definition at line 76 of file setup.c.

#define GZFILE   "sbcab.bin"
 

Definition at line 53 of file setup.c.

Referenced by InstallScriptBasic(), and MyFiles().

#define INSTALL   1
 

Definition at line 56 of file setup.c.

Referenced by InstallScriptBasic(), MyFiles(), MyLinks(), and MyRegs().

#define INSTALL_ABORTED   2
 

Definition at line 612 of file setup.c.

Referenced by end().

#define INSTALL_CANCELLED   1
 

Definition at line 611 of file setup.c.

Referenced by end(), InstallScriptBasic(), MyFiles(), and RemoveScriptBasic().

#define INSTALL_FAILURE   4
 

Definition at line 614 of file setup.c.

Referenced by end(), InstallScriptBasic(), and MyFiles().

#define INSTALL_HEADING   " Install ScriptBasic !"
 

Definition at line 42 of file setup.c.

Referenced by InstallScriptBasic(), and MyFiles().

#define INSTALL_PARTIAL   10
 

Definition at line 619 of file setup.c.

Referenced by end(), and InstallScriptBasic().

#define INSTALL_SUCCESS   3
 

Definition at line 613 of file setup.c.

Referenced by end(), and InstallScriptBasic().

#define KBNEEDED   8000
 

Definition at line 38 of file setup.c.

Referenced by InstallScriptBasic().

#define LOCAL   HKEY_LOCAL_MACHINE
 

Definition at line 47 of file setup.c.

Referenced by DeleteRegistryKey(), MyRegs(), PutRegistryEKey(), PutRegistryKey(), PutSBRegDW(), and PutSBRegString().

#define MAJOR   2
 

Definition at line 33 of file setup.c.

Referenced by InstallScriptBasic(), MyRegs(), and RemoveScriptBasic().

#define MB_STYLE   MB_OK|MB_SYSTEMMODAL|MB_ICONINFORMATION
 

Definition at line 79 of file setup.c.

Referenced by InstallScriptBasic(), and MyFiles().

#define MINOR   0
 

Definition at line 34 of file setup.c.

Referenced by InstallScriptBasic(), MyRegs(), and RemoveScriptBasic().

#define MODUDOC X,
 )     {CSIDL_PROGRAMS,BASIC_NAME"\\Documentation\\" X ".LNK", "mod_" Y ".chm","Link to mod_" X ".chm", "\027",FALSE,"DOC\\"},\
 

Referenced by MyLinks().

#define NEXT   2
 

Definition at line 61 of file setup.c.

#define REMOVE   2
 

Definition at line 57 of file setup.c.

Referenced by MyFiles(), MyRegs(), and RemoveScriptBasic().

#define REMOVE_CANCELLED   8
 

Definition at line 617 of file setup.c.

Referenced by end().

#define REMOVE_FAILURE   7
 

Definition at line 616 of file setup.c.

Referenced by end().

#define REMOVE_HEADING   " Remove ScriptBasic !"
 

Definition at line 43 of file setup.c.

#define REMOVE_SUCCESS   6
 

Definition at line 615 of file setup.c.

Referenced by end(), and RemoveScriptBasic().

#define RESET   1
 

Definition at line 60 of file setup.c.

#define ROOT   HKEY_CLASSES_ROOT
 

Definition at line 48 of file setup.c.

Referenced by MyRegs().

#define SILENT   9
 

Definition at line 618 of file setup.c.

Referenced by end().

#define SOFT   "SOFTWARE\\"
 

Definition at line 49 of file setup.c.

#define SOFT   "SOFTWARE\\"
 

Definition at line 49 of file setup.c.

Referenced by MyRegs().

#define SSLEN   1024
 

Definition at line 82 of file setup.c.

Referenced by brushup(), CreateShellLink(), DeleteFromPath(), DeleteFromPathEx(), DeleteRegistryKey(), failReport(), GetRegistryKey(), GetSBRegString(), InstallScriptBasic(), MyFiles(), MyLinks(), MyRegs(), pathdialog(), PutRegistryEKey(), PutRegistryKey(), PutSBRegDW(), PutSBRegString(), RemoveScriptBasic(), and WinMain().

#define UNINSTALL   "SOFTWARE\\MICROSOFT\\WINDOWS\\CURRENTVERSION\\UNINSTALL\\"
 

Definition at line 50 of file setup.c.

Referenced by MyRegs().

#define VERSION_TEXT   "2.0.0"
 

Definition at line 32 of file setup.c.

Referenced by InstallScriptBasic(), and RemoveScriptBasic().


Typedef Documentation

typedef struct linkinfo LINKINFO
 


Function Documentation

char* app char *  trail  ) 
 

Definition at line 103 of file setup.c.

References i, memcpy(), pszInstallPath, and result.

Referenced by MyRegs().

char* brushup char *  path  ) 
 

Definition at line 506 of file setup.c.

References buf, i, NULL, and SSLEN.

Referenced by InstallScriptBasic(), MyRegs(), and WinMain().

void brushupinline char *  path  ) 
 

Definition at line 530 of file setup.c.

References i, j, NULL, and return.

Referenced by MyFiles().

HRESULT CreateShellLink LINKINFO li,
char *  path
 

Definition at line 1145 of file setup.c.

References linkinfo::desc, linkinfo::file, linkinfo::folder, linkinfo::icon, linkinfo::link, NULL, sprintf(), SSLEN, and string.

Referenced by MyLinks().

void DeleteFromPath char *  Path  ) 
 

Definition at line 811 of file setup.c.

References i, j, logit(), logs, NULL, s, slen, sprintf(), and SSLEN.

Referenced by MyRegs().

void DeleteFromPathEx char *  Path,
char *  Ext
 

Definition at line 865 of file setup.c.

References logit(), logs, NULL, s, sprintf(), and SSLEN.

Referenced by MyRegs().

static int DeleteRegistryKey HKEY  start,
char *  keyname,
char *  subkey
[static]
 

Definition at line 169 of file setup.c.

References failReport(), GlobalSuccessFlag, LOCAL, logs, RegCloseKey(), sprintf(), and SSLEN.

Referenced by MyRegs().

HRESULT DeleteShellLink LINKINFO li  ) 
 

Definition at line 1218 of file setup.c.

References linkinfo::folder, linkinfo::link, logit(), logs, NULL, and sprintf().

Referenced by MyLinks().

void end int  m  ) 
 

Definition at line 621 of file setup.c.

References INSTALL_ABORTED, INSTALL_CANCELLED, INSTALL_FAILURE, INSTALL_PARTIAL, INSTALL_SUCCESS, logit(), MyMessage(), NULL, progress(), REMOVE_CANCELLED, REMOVE_FAILURE, REMOVE_SUCCESS, ret, and SILENT.

Referenced by InstallScriptBasic(), MyFiles(), and RemoveScriptBasic().

int failReport char *  key,
char *  action
 

Definition at line 120 of file setup.c.

References logit(), logs, NULL, sprintf(), and SSLEN.

Referenced by DeleteRegistryKey(), GetRegistryKey(), PutRegistryEKey(), PutRegistryKey(), PutSBRegDW(), and PutSBRegString().

char* GetRegistryKey char *  keyname,
char *  name
 

Definition at line 462 of file setup.c.

References failReport(), GlobalSuccessFlag, logs, NULL, RegCloseKey(), sprintf(), and SSLEN.

Referenced by MyRegs().

DWORD GetSBRegDW char *  name,
DWORD *  DW
 

Definition at line 254 of file setup.c.

References cbData, NULL, and RegCloseKey().

Referenced by WinMain().

char* GetSBRegString char *  name  ) 
 

Definition at line 213 of file setup.c.

References cbData, NULL, RegCloseKey(), SSLEN, and strcpy().

Referenced by RemoveScriptBasic(), and WinMain().

UINT CALLBACK HookProc HWND  hdl,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam
 

Definition at line 711 of file setup.c.

References rc.

Referenced by pathdialog().

int InstallQuestionYN char *  pszText  ) 
 

Definition at line 495 of file setup.c.

References NULL.

Referenced by InstallScriptBasic(), MyFiles(), and RemoveScriptBasic().

void InstallScriptBasic  ) 
 

Definition at line 1418 of file setup.c.

References brushup(), BUILD, cancel, CloseHandle(), DEFAULT_PATH, dwBuild, dwMajor, dwMinor, end(), fp, GlobalSuccessFlag, GZFILE, IDD_PATHDIALOG, INSTALL, INSTALL_CANCELLED, INSTALL_FAILURE, INSTALL_HEADING, INSTALL_PARTIAL, INSTALL_SUCCESS, InstallQuestionYN(), KBNEEDED, logfilename, logit(), logs, MAJOR, MB_STYLE, MINOR, MyFiles(), MyLinks(), MyMessage(), MyRegs(), NULL, pathdialog(), progress(), pszInstallPath, s, Sleep, sprintf(), SSLEN, strcpy(), string, this_instance, total_progress, and VERSION_TEXT.

Referenced by WinMain().

void logit char *  text  ) 
 

Definition at line 550 of file setup.c.

References fflush(), logfilename, NULL, sprintf(), and temppath.

Referenced by DeleteFromPath(), DeleteFromPathEx(), DeleteShellLink(), end(), failReport(), InstallScriptBasic(), MyFiles(), MyMessage(), MyRegs(), noprogress(), progress(), and WinMain().

int MyFiles int  mode  ) 
 

Definition at line 1332 of file setup.c.

References brushupinline(), buf, end(), file_deltree(), file_exists(), file_MakeDirectory(), fp, gzclose(), GZFILE, INSTALL, INSTALL_CANCELLED, INSTALL_FAILURE, INSTALL_HEADING, InstallQuestionYN(), logit(), MB_STYLE, MyMessage(), noprogress(), NULL, progress(), progress_wait, pszInstallPath, REMOVE, s, sprintf(), SSLEN, strcpy(), and string.

Referenced by InstallScriptBasic(), and RemoveScriptBasic().

int MyLinks int  mode  ) 
 

Definition at line 1241 of file setup.c.

References BASDOC_ICON, BASIC_ICON, BASIC_NAME, CreateShellLink(), DeleteShellLink(), INSTALL, linkinfo::link, MODUDOC, NULL, progress(), pszInstallPath, res, sprintf(), SSLEN, strcpy(), and string.

Referenced by InstallScriptBasic(), and RemoveScriptBasic().

int MyMessage HWND  handle,
LPCSTR  text,
LPCSTR  title,
UINT  style
 

Definition at line 599 of file setup.c.

References logit(), logs, and sprintf().

Referenced by end(), InstallScriptBasic(), MyFiles(), and RemoveScriptBasic().

int MyRegs int  mode  ) 
 

Definition at line 914 of file setup.c.

References app(), BASIC_EXE, BASIC_EXTENSION, BASIC_ICON, BASIC_NAME, BASIC_SETUP, brushup(), BUILD, DeleteFromPath(), DeleteFromPathEx(), DeleteRegistryKey(), GetRegistryKey(), INSTALL, LOCAL, logit(), logs, MAJOR, MINOR, NULL, progress(), pszInstallPath, PutRegistryEKey(), PutRegistryKey(), PutSBRegDW(), PutSBRegString(), REMOVE, ROOT, SOFT, sprintf(), SSLEN, string, and UNINSTALL.

Referenced by InstallScriptBasic(), and RemoveScriptBasic().

void noprogress char *  msg  ) 
 

Definition at line 1118 of file setup.c.

References IDC_PROGRESSTEXT, logit(), logs, NULL, progress_wait, progressbox, sprintf(), timerid, and timermsg.

Referenced by MyFiles().

BOOL CALLBACK pathdialog HWND  handle,
UINT  message,
WPARAM  wparam,
LPARAM  lparam
 

Definition at line 733 of file setup.c.

References buf, HookProc(), IDC_BROWSE, IDD_EXPLANATION, IDINSTPATH, NULL, pszInstallPath, rc, ret, SSLEN, strcpy(), and this_instance.

Referenced by InstallScriptBasic().

void progress char *  msg  ) 
 

Definition at line 1061 of file setup.c.

References IDC_PROGRESSTEXT, IDD_PROGRESSDIALOG, logit(), logs, NULL, progress_wait, progressdialog(), sprintf(), this_instance, and total_progress.

Referenced by end(), InstallScriptBasic(), MyFiles(), MyLinks(), and MyRegs().

BOOL CALLBACK progressdialog HWND  handle,
UINT  message,
WPARAM  wparam,
LPARAM  lparam
 

Definition at line 1028 of file setup.c.

References rc.

Referenced by progress().

int PutRegistryEKey HKEY  start,
char *  keyname,
char *  name,
char *  content
 

Definition at line 337 of file setup.c.

References failReport(), GlobalSuccessFlag, LOCAL, logs, NULL, sprintf(), and SSLEN.

Referenced by MyRegs().

int PutRegistryKey HKEY  start,
char *  keyname,
char *  name,
char *  content
 

Definition at line 292 of file setup.c.

References failReport(), GlobalSuccessFlag, LOCAL, logs, NULL, sprintf(), and SSLEN.

Referenced by MyRegs().

int PutSBRegDW HKEY  start,
char *  keyname,
char *  name,
DWORD  DW
 

Definition at line 429 of file setup.c.

References failReport(), GlobalSuccessFlag, LOCAL, logs, NULL, sprintf(), and SSLEN.

Referenced by MyRegs().

int PutSBRegString HKEY  start,
char *  keyname,
char *  name,
char *  content
 

Definition at line 384 of file setup.c.

References failReport(), GlobalSuccessFlag, LOCAL, logs, NULL, sprintf(), and SSLEN.

Referenced by MyRegs().

void RemoveScriptBasic  ) 
 

Definition at line 1601 of file setup.c.

References BUILD, dwBuild, dwMajor, dwMinor, end(), GetSBRegString(), INSTALL_CANCELLED, InstallQuestionYN(), MAJOR, MINOR, MyFiles(), MyLinks(), MyMessage(), MyRegs(), NULL, pszInstallPath, REMOVE, REMOVE_SUCCESS, sprintf(), SSLEN, string, total_progress, and VERSION_TEXT.

Referenced by WinMain().

int WINAPI WinMain HINSTANCE  _this_instance,
HINSTANCE  prev_instance,
LPSTR  commandline,
int  win_state
 

Definition at line 1655 of file setup.c.

References brushup(), currentpath, dwBuild, dwMajor, dwMinor, GetSBRegDW(), GetSBRegString(), install, InstallScriptBasic(), logit(), logs, NULL, progress_wait, pszInstallPath, RemoveScriptBasic(), sprintf(), SSLEN, string, strnicmp(), temppath, and this_instance.


Variable Documentation

int cancel
 

Definition at line 95 of file setup.c.

Referenced by InstallScriptBasic().

int count = 0 [static]
 

Definition at line 1055 of file setup.c.

Referenced by fmt_cdig(), p_count(), p_ere_exp(), and p_simp_re().

char* currentpath
 

Definition at line 94 of file setup.c.

Referenced by WinMain().

DWORD dwBuild
 

Definition at line 100 of file setup.c.

Referenced by InstallScriptBasic(), RemoveScriptBasic(), and WinMain().

DWORD dwMajor
 

Definition at line 100 of file setup.c.

Referenced by InstallScriptBasic(), RemoveScriptBasic(), and WinMain().

DWORD dwMinor
 

Definition at line 100 of file setup.c.

Referenced by InstallScriptBasic(), RemoveScriptBasic(), and WinMain().

int GlobalSuccessFlag = 1
 

Definition at line 85 of file setup.c.

Referenced by DeleteRegistryKey(), GetRegistryKey(), InstallScriptBasic(), PutRegistryEKey(), PutRegistryKey(), PutSBRegDW(), and PutSBRegString().

HWND hwndPB = NULL [static]
 

Definition at line 1057 of file setup.c.

int install
 

Definition at line 93 of file setup.c.

Referenced by WinMain().

char logfilename[SSLEN]
 

Definition at line 97 of file setup.c.

Referenced by InstallScriptBasic(), and logit().

char logs[10000]
 

Definition at line 92 of file setup.c.

Referenced by DeleteFromPath(), DeleteFromPathEx(), DeleteRegistryKey(), DeleteShellLink(), failReport(), GetRegistryKey(), InstallScriptBasic(), MyMessage(), MyRegs(), noprogress(), progress(), PutRegistryEKey(), PutRegistryKey(), PutSBRegDW(), PutSBRegString(), and WinMain().

int progress_wait
 

Definition at line 98 of file setup.c.

Referenced by MyFiles(), noprogress(), progress(), and WinMain().

HWND progressbox = NULL [static]
 

Definition at line 1056 of file setup.c.

Referenced by noprogress().

char* pszInstallPath
 

Definition at line 89 of file setup.c.

Referenced by app(), InstallScriptBasic(), MyFiles(), MyLinks(), MyRegs(), pathdialog(), RemoveScriptBasic(), and WinMain().

RECT rc
 

Definition at line 1054 of file setup.c.

Referenced by fork(), HookProc(), pathdialog(), progressdialog(), resume_child(), and sync_with_child().

char string[SSLEN]
 

Definition at line 1058 of file setup.c.

char string[SSLEN]
 

Definition at line 96 of file setup.c.

Referenced by CreateShellLink(), InstallScriptBasic(), MyFiles(), MyLinks(), MyRegs(), RemoveScriptBasic(), and WinMain().

char* temppath
 

Definition at line 91 of file setup.c.

Referenced by logit(), and WinMain().

HINSTANCE this_instance
 

Definition at line 90 of file setup.c.

Referenced by InstallScriptBasic(), pathdialog(), progress(), and WinMain().

int thumb
 

Definition at line 1059 of file setup.c.

int timerid
 

Definition at line 1052 of file setup.c.

Referenced by noprogress().

MSG timermsg
 

Definition at line 1053 of file setup.c.

Referenced by noprogress().

int total_progress
 

Definition at line 83 of file setup.c.

Referenced by InstallScriptBasic(), progress(), and RemoveScriptBasic().


Generated on Sun Mar 12 23:56:37 2006 for ScriptBasic by  doxygen 1.4.6-NO