summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--binding.gyp16
-rw-r--r--index.cc12
-rw-r--r--utils.h8
3 files changed, 26 insertions, 10 deletions
diff --git a/binding.gyp b/binding.gyp
index e0c5e4c..c4788fe 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -2,7 +2,21 @@
"targets": [
{
"target_name": "winutils",
- "sources": [ "index.cc" ]
+ "sources": [ "index.cc" ],
+
+ 'conditions': [
+ [ 'OS=="win"', {
+ 'defines': [
+ 'UNICODE=1',
+ '_UNICODE=1',
+ '_SQLNCLI_ODBC_',
+ ],
+ 'libraries': [
+ 'odbc32.lib'
+ ],
+ }
+ ]
+ ]
}
]
}
diff --git a/index.cc b/index.cc
index 289c2b9..59e359d 100644
--- a/index.cc
+++ b/index.cc
@@ -202,17 +202,19 @@ void elevate(const v8::FunctionCallbackInfo<Value>& args) {
String::Utf8Value exePathArg(args[0]);
std::string exePath(*exePathArg);
+ std::wstring w_exePath = s2ws(exePath);
String::Utf8Value cmdLineArg(args[1]);
std::string cmdLine(*cmdLineArg);
+ std::wstring w_cmdLine = s2ws(cmdLine);
SHELLEXECUTEINFO shExInfo = {0};
shExInfo.cbSize = sizeof(shExInfo);
shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
shExInfo.hwnd = 0;
- shExInfo.lpVerb = "runas";
- shExInfo.lpFile = exePath.c_str();
- shExInfo.lpParameters = cmdLine.c_str();
+ shExInfo.lpVerb = L"runas";
+ shExInfo.lpFile = w_exePath.c_str();
+ shExInfo.lpParameters = w_cmdLine.c_str();
shExInfo.lpDirectory = 0;
shExInfo.nShow = SW_SHOW;
shExInfo.hInstApp = 0;
@@ -241,12 +243,12 @@ void GetSystem32Path(const v8::FunctionCallbackInfo<Value>& args) {
int size = WideCharToMultiByte(CP_UTF8, 0, szPath, -1, NULL, 0, NULL, NULL);
if (size > 0) {
buffer.resize(size);
- WideCharToMultiByte(CP_UTF8, 0, szPath, -1, static_cast<BYTE*>(&buffer[0]), buffer.size(), NULL, NULL);
+ WideCharToMultiByte(CP_UTF8, 0, szPath, -1, &buffer[0], buffer.size(), NULL, NULL);
}
else {
isolate->ThrowException(Exception::TypeError(
String::NewFromUtf8(isolate, "Failed to convert string")));
- return
+ return;
}
std::string string(&buffer[0]);
#else
diff --git a/utils.h b/utils.h
index aa9d43f..effe318 100644
--- a/utils.h
+++ b/utils.h
@@ -71,9 +71,9 @@ std::wstring s2ws(const std::string& s)
{
int len;
int slength = (int)s.length() + 1;
- len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0);
+ len = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), slength, 0, 0);
wchar_t* buf = new wchar_t[len];
- MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len);
+ MultiByteToWideChar(CP_UTF8, 0, s.c_str(), slength, buf, len);
std::wstring r(buf);
delete[] buf;
return r;
@@ -84,9 +84,9 @@ std::string ws2s(const std::wstring& s)
{
int len;
int slength = (int)s.length() + 1;
- len = WideCharToMultiByte(CP_ACP, 0, s.c_str(), slength, 0, 0, 0, 0);
+ len = WideCharToMultiByte(CP_UTF8, 0, s.c_str(), slength, 0, 0, 0, 0);
char* buf = new char[len];
- WideCharToMultiByte(CP_ACP, 0, s.c_str(), slength, buf, len, 0, 0);
+ WideCharToMultiByte(CP_UTF8, 0, s.c_str(), slength, buf, len, 0, 0);
std::string r(buf);
delete[] buf;
return r;