13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
"""Win32-specific helper functions
144
144
trace.note('Cannot debug memory on win32 without ctypes'
145
145
' or win32process')
147
trace.note('WorkingSize %8d kB', info['WorkingSetSize'] / 1024)
148
trace.note('PeakWorking %8d kB', info['PeakWorkingSetSize'] / 1024)
148
trace.note('WorkingSize %7dKB'
149
'\tPeakWorking %7dKB\t%s',
150
info['WorkingSetSize'] / 1024,
151
info['PeakWorkingSetSize'] / 1024,
151
trace.note('PagefileUsage %8d kB', info.get('PagefileUsage', 0) / 1024)
152
trace.note('PeakPagefileUsage %8d kB', info.get('PeakPagefileUsage', 0) / 1024)
153
trace.note('PrivateUsage %8d kB', info.get('PrivateUsage', 0) / 1024)
155
trace.note('%s', message)
156
trace.note('WorkingSize %8d KB', info['WorkingSetSize'] / 1024)
157
trace.note('PeakWorking %8d KB', info['PeakWorkingSetSize'] / 1024)
158
trace.note('PagefileUsage %8d KB', info.get('PagefileUsage', 0) / 1024)
159
trace.note('PeakPagefileUsage %8d KB', info.get('PeakPagefileUsage', 0) / 1024)
160
trace.note('PrivateUsage %8d KB', info.get('PrivateUsage', 0) / 1024)
154
161
trace.note('PageFaultCount %8d', info.get('PageFaultCount', 0))
279
286
If location cannot be obtained return system drive root,
282
Returned value can be unicode or plain sring.
289
Returned value can be unicode or plain string.
283
290
To convert plain string to unicode use
284
291
s.decode(osutils.get_user_encoding())
302
309
"""Return user name as login name.
303
310
If name cannot be obtained return None.
305
Returned value can be unicode or plain sring.
312
Returned value can be unicode or plain string.
306
313
To convert plain string to unicode use
307
314
s.decode(osutils.get_user_encoding())
448
454
def get_app_path(appname):
449
455
"""Look up in Windows registry for full path to application executable.
450
Typicaly, applications create subkey with their basename
456
Typically, applications create subkey with their basename
451
457
in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\
453
459
:param appname: name of application (if no filename extension
481
487
"""Set file attributes to hidden if possible"""
482
488
if has_win32file:
483
489
win32file.SetFileAttributes(path, win32file.FILE_ATTRIBUTE_HIDDEN)
492
if has_ctypes and winver != 'Windows 98':
493
def get_unicode_argv():
494
LPCWSTR = ctypes.c_wchar_p
496
POINTER = ctypes.POINTER
497
prototype = ctypes.WINFUNCTYPE(LPCWSTR)
498
GetCommandLine = prototype(("GetCommandLineW",
499
ctypes.windll.kernel32))
500
prototype = ctypes.WINFUNCTYPE(POINTER(LPCWSTR), LPCWSTR, POINTER(INT))
501
CommandLineToArgv = prototype(("CommandLineToArgvW",
502
ctypes.windll.shell32))
504
pargv = CommandLineToArgv(GetCommandLine(), ctypes.byref(c))
505
# Skip the first argument, since we only care about parameters
506
argv = [pargv[i] for i in range(1, c.value)]
507
if getattr(sys, 'frozen', None) is None:
508
# Invoked via 'python.exe' which takes the form:
509
# python.exe [PYTHON_OPTIONS] C:\Path\bzr [BZR_OPTIONS]
510
# we need to get only BZR_OPTIONS part,
511
# so let's using sys.argv[1:] as reference to get the tail
513
tail_len = len(sys.argv[1:])
514
ix = len(argv) - tail_len
518
get_unicode_argv = None