/[winpt]/trunk/Src/wptW32API.cpp
ViewVC logotype

Diff of /trunk/Src/wptW32API.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 278 by twoaday, Mon Jan 15 22:02:04 2007 UTC revision 328 by twoaday, Fri Sep 25 16:07:38 2009 UTC
# Line 1  Line 1 
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   *   *
# Line 32  Line 32 
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);
# Line 125  get_filename_dlg (HWND hwnd, int id, con Line 126  get_filename_dlg (HWND hwnd, int id, con
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;
# Line 133  get_filename_dlg (HWND hwnd, int id, con Line 135  get_filename_dlg (HWND hwnd, int id, con
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));
# Line 179  get_fileopen_dlg (HWND hwnd, const char Line 184  get_fileopen_dlg (HWND hwnd, const char
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    
# Line 333  make_filename (const char *path, const c Line 338  make_filename (const char *path, const c
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 */
# Line 512  get_file_version (const char *fname, Line 517  get_file_version (const char *fname,
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;
# Line 607  get_temp_name (char *buf, DWORD buflen, Line 612  get_temp_name (char *buf, DWORD buflen,
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;
# Line 667  GetDlgItemText_utf8 (HWND dlg, int id, c Line 663  GetDlgItemText_utf8 (HWND dlg, int id, c
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)

Legend:
Removed from v.278  
changed lines
  Added in v.328

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26