24 #define SEESTR " (SEE)"
25 #define SEESTR2 "SEE "
35 "SQLite ODBC (UTF-8) Driver",
36 "SQLite3 ODBC Driver" SEESTR,
41 "SQLite UTF-8 Datasource",
42 "SQLite3 " SEESTR2 "Datasource",
48 "sqlite3odbc" SEEEXT ".dll",
51 #ifdef WITH_SQLITE_DLLS
52 static char *EngineDLL[
NUMDRVS] = {
74 WORD errlen, errmax =
sizeof (errmsg) - 1;
80 rc = SQLInstallerError(err, &code, errmsg, errmax, &errlen);
81 if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) {
82 MessageBox(NULL, errmsg, name,
83 MB_ICONSTOP|MB_OK|MB_TASKMODAL|MB_SETFOREGROUND);
87 }
while (rc != SQL_NO_DATA);
101 char firstpat[MAX_PATH];
102 WIN32_FIND_DATA fdata;
106 if (strncmp(dllname,
"sqlite3", 7)) {
111 strcpy(firstpat, path);
112 strcat(firstpat,
"\\");
114 strcat(firstpat,
"sqlite3_mod*.dll");
115 h = FindFirstFile(firstpat, &fdata);
116 if (h == INVALID_HANDLE_VALUE) {
121 DeleteFile(fdata.cFileName);
125 sprintf(buf,
"%s\\%s", path, fdata.cFileName);
126 if (!CopyFile(fdata.cFileName, buf, 0)) {
127 sprintf(buf,
"Copy %s to %s failed", fdata.cFileName, path);
128 MessageBox(NULL, buf,
"CopyFile",
129 MB_ICONSTOP|MB_OK|MB_TASKMODAL|MB_SETFOREGROUND);
134 }
while (FindNextFile(h, &fdata));
135 err = GetLastError();
137 return err == ERROR_NO_MORE_FILES;
150 InUn(
int remove,
char *drivername,
char *dllname,
char *dll2name,
char *dsname)
152 char path[301], driver[300], attr[300], inst[400], inst2[400];
153 WORD pathmax =
sizeof (path) - 1, pathlen;
154 DWORD usecnt, mincnt;
156 if (SQLInstallDriverManager(path, pathmax, &pathlen)) {
159 sprintf(driver,
"%s;Driver=%s;Setup=%s;",
160 drivername, dllname, dllname);
169 SQLInstallDriverEx(driver, NULL, path, pathmax, &pathlen,
170 ODBC_INSTALL_INQUIRY, &usecnt);
171 sprintf(driver,
"%s;Driver=%s\\%s;Setup=%s\\%s;",
172 drivername, path, dllname, path, dllname);
180 sprintf(inst,
"%s\\%s", path, dllname);
182 sprintf(inst2,
"%s\\%s", path, dll2name);
184 if (!
remove && usecnt > 0) {
186 if (GetFileAttributes(dllname) != INVALID_FILE_ATTRIBUTES &&
187 CopyFile(dllname, inst, 0) &&
189 if (dll2name != NULL) {
190 CopyFile(dll2name, inst2, 0);
195 mincnt =
remove ? 1 : 0;
196 while (usecnt != mincnt) {
197 if (!SQLRemoveDriver(driver, TRUE, &usecnt)) {
202 if (!SQLRemoveDriver(driver, TRUE, &usecnt)) {
213 sprintf(buf,
"%s uninstalled.", drivername);
214 MessageBox(NULL, buf,
"Info",
215 MB_ICONINFORMATION|MB_OK|MB_TASKMODAL|
222 sprintf(attr,
"DSN=%s;Database=", dsname);
230 SQLConfigDataSource(NULL, ODBC_REMOVE_SYS_DSN, drivername, attr);
233 if (GetFileAttributes(dllname) == INVALID_FILE_ATTRIBUTES) {
236 if (!CopyFile(dllname, inst, 0)) {
239 sprintf(buf,
"Copy %s to %s failed", dllname, inst);
240 MessageBox(NULL, buf,
"CopyFile",
241 MB_ICONSTOP|MB_OK|MB_TASKMODAL|MB_SETFOREGROUND);
244 if (dll2name != NULL && !CopyFile(dll2name, inst2, 0)) {
247 sprintf(buf,
"Copy %s to %s failed", dll2name, inst2);
248 MessageBox(NULL, buf,
"CopyFile",
249 MB_ICONSTOP|MB_OK|MB_TASKMODAL|MB_SETFOREGROUND);
255 if (!SQLInstallDriverEx(driver, path, path, pathmax, &pathlen,
256 ODBC_INSTALL_COMPLETE, &usecnt)) {
263 sprintf(attr,
"DSN=%s;Database=;", dsname);
271 SQLConfigDataSource(NULL, ODBC_REMOVE_SYS_DSN, drivername, attr);
272 if (!SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, drivername, attr)) {
292 WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
293 LPSTR lpszCmdLine,
int nCmdShow)
299 GetModuleFileName(NULL, path,
sizeof (path));
305 p = strrchr(path,
'\\');
311 SetCurrentDirectory(path);
313 remove = strstr(p,
"uninst") != NULL;
314 quiet = strstr(p,
"instq") != NULL;
315 nosys = strstr(p,
"nosys") != NULL;
316 for (i = 0; i <
NUMDRVS; i++) {
317 #ifdef WITH_SQLITE_DLLS
324 for (i = 1; i <
NUMDRVS; i++) {
325 ret[0] = ret[0] || ret[i];
327 if (!
remove && ret[0]) {
329 MessageBox(NULL,
"SQLite ODBC Driver(s) installed.",
"Info",
330 MB_ICONINFORMATION|MB_OK|MB_TASKMODAL|MB_SETFOREGROUND);
static BOOL ProcessErrorMessages(char *name)
Handler for ODBC installation error messages.
static BOOL CopyOrDelModules(char *dllname, char *path, BOOL del)
Copy or delete SQLite3 module DLLs.
static char * DriverName[NUMDRVS]
static BOOL InUn(int remove, char *drivername, char *dllname, char *dll2name, char *dsname)
Driver installer/uninstaller.
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
Main function of installer/uninstaller.
static char * DSName[NUMDRVS]
static char * DriverDLL[NUMDRVS]