source: dev/trunk/ab5.0/abdev/ab_common/src/Environment.cpp

Last change on this file was 829, checked in by イグトランス (egtra), 13 years ago

svn:eol-styleとsvn:mime-type(文字コード指定含む)の設定

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/plain; charset=Shift_JIS
File size: 2.5 KB
Line 
1#include "stdafx.h"
2#include <uxtheme.h>
3
4DWORD const PROCESS_DEP_ENABLE = 0x00000001;
5
6std::string ActiveBasic::Common::Environment::rootPath;
7bool ActiveBasic::Common::Environment::isRemoveExternal = false;
8
9using namespace ActiveBasic::Common;
10
11void Environment::SetAbdevRootPath( const std::string &rootPath )
12{
13 Environment::rootPath = Jenga::Common::Path::MakeFullPath( rootPath, Jenga::Common::Environment::GetAppDir() );
14}
15const std::string Environment::GetAbdevRootPath()
16{
17 if( rootPath.empty() )
18 {
19 SetAbdevRootPath( "" );
20 }
21 return rootPath;
22}
23
24const std::string Environment::GetUserAppDir()
25{
26 return Jenga::Common::Environment::GetUserAppDir() + "\\ActiveBasic";
27}
28
29const std::string Environment::GetCompilerExePath( Platform::EnumType platform )
30{
31 switch( platform )
32 {
33 case Platform::X86:
34 return rootPath + "\\bin\\x86\\abc.exe";
35 case Platform::X64:
36 return rootPath + "\\bin\\x64\\abc.exe";
37 }
38 throw;
39}
40
41void* operator new( std::size_t n )
42{
43 if ( void* p = dlmalloc(n) ){
44 return p;
45 }
46 else{
47 throw std::bad_alloc();
48 }
49}
50
51void* operator new[]( std::size_t n )
52{
53 return ::operator new( n );
54}
55
56void operator delete( void* p )
57{
58 dlfree( p );
59}
60
61void operator delete[]( void* p )
62{
63 ::operator delete( p );
64}
65
66typedef HRESULT (WINAPI* PFN_EnableThemeDialogTexture)(HWND, DWORD);
67
68HMODULE hmodUxTheme = LoadLibrary("uxtheme");
69
70HRESULT ApplyDialogTexture( HWND hwnd )
71{
72 if( hmodUxTheme )
73 {
74 if( PFN_EnableThemeDialogTexture pfn = reinterpret_cast<PFN_EnableThemeDialogTexture>(
75 GetProcAddress(hmodUxTheme, "EnableThemeDialogTexture")) )
76 {
77 return pfn(hwnd, ETDT_ENABLETAB);
78 }
79 }
80 return E_NOTIMPL;
81}
82
83BOOL ActiveBasic::Common::EnableNX()
84{
85 typedef BOOL (WINAPI* PFNSETDEP)(DWORD);
86
87 HMODULE hmodKernel = GetModuleHandle(TEXT("KERNEL32.DLL"));
88 if (PFNSETDEP pfnSetDEP = reinterpret_cast<PFNSETDEP>(GetProcAddress(hmodKernel, "SetProcessDEPPolicy")))
89 {
90 return pfnSetDEP(PROCESS_DEP_ENABLE);
91 }
92 else
93 {
94 return FALSE;
95 }
96}
97
98void ActiveBasic::Common::SetHeapOptions()
99{
100// SetDllDirectory(_T(""));
101 HMODULE hmodKernel = GetModuleHandle(TEXT("KERNEL32.DLL"));
102
103 typedef BOOL (WINAPI* HSI)(HANDLE, HEAP_INFORMATION_CLASS ,PVOID, SIZE_T);
104 HSI pHsi = reinterpret_cast<HSI>(GetProcAddress(hmodKernel, "HeapSetInformation"));
105 if (!pHsi)
106 {
107 return;
108 }
109
110 ULONG enableLFH = 2;
111 pHsi(GetProcessHeap(), HeapCompatibilityInformation, &enableLFH, sizeof enableLFH);
112
113#ifndef HeapEnableTerminationOnCorruption
114# define HeapEnableTerminationOnCorruption (HEAP_INFORMATION_CLASS)1
115#endif
116
117 pHsi(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
118}
Note: See TracBrowser for help on using the repository browser.