1 |
/* wptW32API.cpp - Common W32 API functions |
/* wptW32API.cpp - Common W32 API functions |
2 |
* Copyright (C) 2001, 2002, 2003, 2005, 2006 Timo Schulz |
* Copyright (C) 2001-2003, 2005-2006, 2009 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
32 |
#include "wptVersion.h" |
#include "wptVersion.h" |
33 |
#include "wptUTF8.h" |
#include "wptUTF8.h" |
34 |
#include "wptTypes.h" |
#include "wptTypes.h" |
35 |
|
#include "StringBuffer.h" |
36 |
|
|
37 |
|
|
38 |
extern "C" void _SHFree (void *p); |
extern "C" void _SHFree (void *p); |
126 |
const char *filter, const char *name) |
const char *filter, const char *name) |
127 |
{ |
{ |
128 |
static char file[2*MAX_PATH+1] = ""; |
static char file[2*MAX_PATH+1] = ""; |
129 |
|
char _filter[512]; |
130 |
char workdir[MAX_PATH+1]; |
char workdir[MAX_PATH+1]; |
131 |
char *sel_file = NULL; |
char *sel_file = NULL; |
132 |
OPENFILENAME open; |
OPENFILENAME open; |
135 |
strcpy (file, name); |
strcpy (file, name); |
136 |
else |
else |
137 |
memset (file, 0, sizeof (file)); |
memset (file, 0, sizeof (file)); |
138 |
if (!filter) |
if (!filter) { |
139 |
filter = "All Files (*.*)\0*.*\0\0"; |
strcpy (_filter, _("All Files (*.*)")); |
140 |
|
memcpy (_filter+strlen (_filter)+1, "*.*\0\0", 5); |
141 |
|
filter = _filter; |
142 |
|
} |
143 |
|
|
144 |
GetCurrentDirectory (MAX_PATH, workdir); |
GetCurrentDirectory (MAX_PATH, workdir); |
145 |
memset (&open, 0, sizeof (open)); |
memset (&open, 0, sizeof (open)); |
184 |
const char* |
const char* |
185 |
get_folder_dlg (HWND hwnd, const char *title, const char *name) |
get_folder_dlg (HWND hwnd, const char *title, const char *name) |
186 |
{ |
{ |
187 |
static char folder[MAX_PATH+1] = ""; |
static char folder[2*MAX_PATH+1] = ""; |
188 |
BROWSEINFO bi; |
BROWSEINFO bi; |
189 |
ITEMIDLIST *il; |
ITEMIDLIST *il; |
190 |
|
|
338 |
} |
} |
339 |
|
|
340 |
|
|
341 |
/* Generate a file name from a special dirctory. */ |
/* Generates a file name from a special dirctory. */ |
342 |
char* |
char* |
343 |
make_special_filename (int folder, const char *file, const char *ext) |
make_special_filename (int folder, const char *file, const char *ext) |
344 |
{ |
{ |
345 |
BOOL ec; |
BOOL ec; |
346 |
char path[MAX_PATH], *p; |
char path[MAX_PATH+1], *p; |
347 |
size_t n=0; |
size_t n=0; |
348 |
|
|
349 |
/* MSDN: buf must be at least MAX_PATH=256 bytes */ |
/* MSDN: buf must be at least MAX_PATH=256 bytes */ |
517 |
GetFileVersionInfo (file, 0, size, buf); |
GetFileVersionInfo (file, 0, size, buf); |
518 |
|
|
519 |
qlen=0; |
qlen=0; |
520 |
VerQueryValue (buf, "\\", &data, &qlen); |
VerQueryValue (buf, (char*)"\\", &data, &qlen); |
521 |
if (!qlen) { |
if (!qlen) { |
522 |
delete [](char*)buf; |
delete [](char*)buf; |
523 |
return -1; |
return -1; |
612 |
name = tmp; |
name = tmp; |
613 |
} |
} |
614 |
|
|
|
/* In the mobile mode we need to use the current directory |
|
|
as the temp path because no files should be stored outside |
|
|
the USB disk drive. */ |
|
|
#ifdef WINPT_MOBILE |
|
|
memset (buf, 0, buflen); |
|
|
strncpy (buf, name, buflen-1); |
|
|
return 0; |
|
|
#endif |
|
|
|
|
615 |
if (!GetTempPath (buflen - strlen (name) -2, buf)) { |
if (!GetTempPath (buflen - strlen (name) -2, buf)) { |
616 |
log_debug ("GetTempPath() failed ec=%d\n", (int)GetLastError ()); |
log_debug ("GetTempPath() failed ec=%d\n", (int)GetLastError ()); |
617 |
return -1; |
return -1; |
663 |
return len; |
return len; |
664 |
} |
} |
665 |
|
|
666 |
|
int |
667 |
|
html_help_show (int map_id) |
668 |
|
{ |
669 |
|
STARTUPINFO si; |
670 |
|
PROCESS_INFORMATION pi; |
671 |
|
SECURITY_ATTRIBUTES sec_attr; |
672 |
|
char path[2*MAX_PATH+1]; |
673 |
|
|
674 |
|
memset (&sec_attr, 0, sizeof (sec_attr)); |
675 |
|
memset (&si, 0, sizeof (si)); |
676 |
|
si.cb = sizeof (STARTUPINFO); |
677 |
|
memset (&pi, 0, sizeof (pi)); |
678 |
|
//hh.exe -mapid 40 "winpt.$lang.chm" |
679 |
|
|
680 |
|
_snprintf (path, 2*MAX_PATH, "hh.exe -mapid %d winpt.%s.chm", |
681 |
|
map_id, gettext_get_langid ()); |
682 |
|
CreateProcess (NULL, path, &sec_attr, &sec_attr, |
683 |
|
FALSE, 0, NULL, NULL, &si, &pi); |
684 |
|
CloseHandle (pi.hProcess); |
685 |
|
CloseHandle (pi.hThread); |
686 |
|
return 0; |
687 |
|
} |
688 |
|
|
689 |
|
|
690 |
/* Return TRUE if the current user has admin privileges. */ |
/* Return TRUE if the current user has admin privileges. */ |
691 |
BOOL |
BOOL |
692 |
user_is_admin (void) |
user_is_admin (void) |