Giter Site home page Giter Site logo

node-win32ole's Introduction

NAME

node-win32ole - Asynchronous, non-blocking win32ole bindings for node.js powered by v8 engine .

win32ole makes accessibility from node.js to Excel, Word, Access, Outlook, InternetExplorer, WSH ( ActiveXObject / COM ) and so on. It does not need TypeLibrary.

USAGE

Install with npm install win32ole.

It works as... (version 0.1.x)

try{
  var win32ole = require('win32ole');
  // var xl = new ActiveXObject('Excel.Application'); // You may write it as:
  var xl = win32ole.client.Dispatch('Excel.Application');
  xl.Visible = true;
  var book = xl.Workbooks.Add();
  var sheet = book.Worksheets(1);
  try{
    sheet.Name = 'sheetnameA utf8';
    sheet.Cells(1, 2).Value = 'test utf8';
    var rg = sheet.Range(sheet.Cells(2, 2), sheet.Cells(4, 4));
    rg.RowHeight = 5.18;
    rg.ColumnWidth = 0.58;
    rg.Interior.ColorIndex = 6; // Yellow
    var result = book.SaveAs('testfileutf8.xls');
    console.log(result);
  }catch(e){
    console.log('(exception cached)\n' + e);
  }
  xl.ScreenUpdating = true;
  xl.Workbooks.Close();
  xl.Quit();
}catch(e){
  console.log('*** exception cached ***\n' + e);
}

There are 3 ways to make force Garbage Collection for node.js / v8 .

    1. use huge memory to run GC automatically ( causes abnormal termination )
    1. win32ole.force_gc_extension(1);
    1. win32ole.force_gc_internal(1);

see also examples/ole_args_test_client.js

Tutorial and Examples

Other built in functions

  • win32ole.version(void) // returns version string
  • win32ole.printACP(utf8string) // Utf8 to .ACP
  • win32ole.print(utf8string) // ASCII
  • win32ole.gettimeofday(struct timeval &tv, null) // now arg2 is not used
  • win32ole.sleep(long milliseconds, bool withmessage=false, bool with\n=false)
  • win32ole.force_gc_extension(long flag) // now flag is dummy
  • win32ole.force_gc_internal(long flag, string) // now flag is dummy

FEATURES

  • fix BUG: date
  • BUG: A few samples in [email protected] needs '._' ideom.
  • When you use unary operator '!' at the place that needs boolean CONDITION (for example 'while(!obj.status){...}') , you must write 'while(!obj.status._){...}' to complete v8::Object::ToBoolean() conversion. (NamedPropertyHandler will not be called because v8::Object::ToBoolean() is called directly for unary operator '!' instead of v8::Object::valueOf() in ParseUnaryExpression() v8/src/parser.cc .) Do you know how to fake it?
  • V8Variant::OLEGetAttr returns a copy of object, so it uses much memory. I want to fix it.
  • Now '._' ideom is obsoleted.
  • Remove 'node-proxy' from dependencies list.
  • Change default branch to dev0.1.0 .
  • BUG: Some samples in between [email protected] and [email protected] ( examples/maze_creator.js examples/maze_solver.js ) uses huge memory and many disposers will run by v8 GC when maze size is 20*30. I think that each encapsulated V8Variant (by node-proxy) may be big object. So I will try to use v8 accessor handlers ( SetCallAsFunctionHandler / SetNamedPropertyHandler / SetIndexedPropertyHandler ) instead of ( 'noSuchMethod' / 'noSuchGetter' / 'noSuchSetter' ) by node-proxy.
  • So much implements. (can not handle some COM VARIANT types, array etc.)
  • Bug fix. (throws exception when failed to Invoke(), and many test message.)
  • Implement accessors getter, setter and caller. (version 0.1.x) (Some V8Variants were advanced to 0.1.x .)

API

See the API documentation in the wiki.

BUILDING

This project uses VC++ 2008 Express (or later) and Python 2.6 (or later) . (When using Python 2.5, it needs multiprocessing 2.5 back port .) It needs neither ATL nor MFC.

Bulding also requires node-gyp to be installed. You can do this with npm:

npm install -g node-gyp

To obtain and build the bindings:

git clone git://github.com/idobatter/node-win32ole.git
cd node-win32ole
node-gyp configure
node-gyp build

You can also use npm to download and install them:

npm install win32ole

TESTS

mocha is required to run unit tests.

npm install -g mocha
nmake /a test

CONTRIBUTORS

ACKNOWLEDGEMENTS

Inspired Win32OLE

LICENSE

node-win32ole is BSD licensed.

node-win32ole's People

Contributors

antony74 avatar idobatter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-win32ole's Issues

Can not console.log

var win32ole = require('win32ole');
var iTunes = win32ole.client.Dispatch('iTunes.Application');
console.log(iTunes);

Causes a Type Error making debugging a lot harder.

TypeError: Cannot convert object to primitive value
    at String (unknown source)
    at formatValue (util.js:197:12)
    at inspect (util.js:125:10)
    at Object.exports.format (util.js:27:20)
    at Object.exports.log (console.js:25:36)
    at repl:1:10
    at REPLServer.self.eval (repl.js:109:21)
    at Interface.<anonymous> (repl.js:248:12)
    at Interface.EventEmitter.emit (events.js:96:17)
    at Interface._onLine (readline.js:200:10)

Returning errorcde 0x8000ffff when calling C++ ocx's method.

I tried to use win32ole addon to load general activex controls except MS Office's
(Excel, Internet Explorer, etc..).
I encountered the problem that methods of C++ ocx cannot be called.
(VB ocx's did well.)

c:\Program Files\nodejs>node ntgraph.js
ProgID: NTGRAPH.NTGraphCtrl.1
clsid: c2 01 fe c9 46 27 9b 47 96 ab e0 be 99 31 b0 18
OLE error: [AboutBox] hr: 0x8000ffff [AboutBox] = [-552]
??邀?邀?邀?: ??邀?邀?邀?
(It always seems to be appeared at that time you mistake calling 'obj.get { ocv-

getProp() }' <-> 'obj.call { ocv->invoke() }'.) IDispatch::Invoke AutoWrap() failed

CoInitialize and CoCreateInstance were executed nornally.
But Inoke failed returning error code, 0x8000ffff (Catastrophic Failure).

At first, I inspected if initialization of automation process was wrong.
Later, I tested calling same method using VB script.

Set ntgraph = CreateObject("NTGRAPH.NTGraphCtrl.1")
XV = ntgraph.ElementXValue(0, 0)
MsgBox(CStr(XV))

Set ntgraph = Nothing

VB Script returned same error code, 0x8000ffff.
So, I thougt that the cause of failure is not from win32ole but from activex itself.
I found some article about 0x8000ffff error code
and knew that I have to modify the code of activex control.

https://support.microsoft.com/en-us/kb/189065#/en-us/kb/189065
When trying to use an ActiveX Control as an automation server, you need to override the method IsInvokeAllowed. For more information on why this method has to be overridden, please see the REFERENCES section below.

To fix the problem, override IsInvokeAllowed in your ActiveX Control as follows:

https://support.microsoft.com/en-us/kb/189065#/en-us/kb/189065
BOOL CMyOleControl::IsInvokeAllowed (DISPID dispid)
{

// You can check to see if COleControl::m_bInitialized is FALSE
// in your automation functions to limit access.
return TRUE;
}

When I added this code
VBscript returned successfully and win32ole as well.

Thanks.

iTunes on Windows fails AutoWrap()

when connecting to itunes, it can connect to the com object, but fails when getting track information.
I've tried this on a couple of versions of node.

the error is
OLE error: [Item] -2147352570 [Item] IDispatch::GetIDsOfNames AutoWrap() failed

var win32ole = require('win32ole');
var iTunesApp = win32ole.client.Dispatch('iTunes.Application');
var tracks = iTunesApp.LibraryPlaylist.Tracks;
var numTracks = tracks.Count;
console.log('iTunes connected with '+numTracks+' tracks'); /* ********** this log works fine ********** /
// looping songs ///////
while (numTracks != 0)
{
var currTrack = tracks.Item(numTracks); /
************* this fails here ******************** */
console.log(currTrack.Name);
numTracks--;
}

Cannot handle VT_I2 (int16) variants..

I have a program that returns many values as type VT_I2. Is there a way to get node-win32ole to handle these? I notice that it handles 32 and 64 bit ints and can't think of any reason why it WON'T work but.. I've never worked with C++ before.

Thanks!

Cant run win32ole with node-webkit

Hi! Tried to use the module in node-webkit and could not. After calling the module [ var win32ole = require('win32ole'); ] node-webkit crashes. With pure node it works ok. But we never had issues with other modules working with node-webkit. Any clue why this might be happening?

build error

C:\Users\Administrator>npm install win32ole
npm WARN engine [email protected]: wanted: {"node":">= 0.8.18 && < 0.9.0"} (current
: {"node":"4.5.0","npm":"2.15.9"})

[email protected] install C:\Users\Administrator\node_modules\win32ole\node_modules\re
f
node-gyp rebuild

C:\Users\Administrator\node_modules\win32ole\node_modules\ref>if not defined npm
_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bi
n....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild
)
..............\Program Files\nodejs\node_modules\npm\node_modules\node-gy
p\src\win_delay_load_hook.cc(34): error C4430: missing type specifier - int ass
umed. Note: C++ does not support default-int
..............\Program Files\nodejs\node_modules\npm\node_modules\node-gy
p\src\win_delay_load_hook.cc(34): error C2440: 'initializing' : cannot convert
from 'PfnDliHook' to 'int'
..............\Program Files\nodejs\node_modules\npm\node_modules\node-gy
p\src\win_delay_load_hook.cc(34): error C2146: syntax error : missing ';' befor
e identifier '__pfnDliNotifyHook2'
..............\Program Files\nodejs\node_modules\npm\node_modules\node-gy
p\src\win_delay_load_hook.cc(34): error C4430: missing type specifier - int ass
umed. Note: C++ does not support default-int
..............\Program Files\nodejs\node_modules\npm\node_modules\node-gy
p\src\win_delay_load_hook.cc(34): error C2373: '__pfnDliNotifyHook2' : redefini
tion; different type modifiers
..............\Program Files\nodejs\node_modules\npm\node_modules\node-gy
p\src\win_delay_load_hook.cc(34): error C2440: 'initializing' : cannot convert
from 'FARPROC (__stdcall *)(unsigned int,DelayLoadInfo *)' to 'int'
c:\users\administrator.node-gyp\4.5.0\include\node\v8.h(19): fatal error C1083
: Cannot open include file: 'stdint.h': No such file or directory
gyp ERR! build error
gyp ERR! stack Error: C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe fail
ed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules
npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_proces
s.js:200:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodej
s\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Administrator\node_modules\win32ole\node_modules\ref
gyp ERR! node -v v4.5.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs
node_modules\npm\bin\npm-cli.js" "install" "win32ole"
npm ERR! node v4.5.0
npm ERR! npm v2.15.9
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the ref package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs ref
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls ref
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Administrator\npm-debug.log

node.js equivalent when com api returns com object

Hello,
Thanks for the great module. but I' m using a com object which will return another com object's address through it's output parameter. so how can I write the equivalent code in node.js?

//C++ sample code:
sub_com_obj_type *pSubComObj;
pComObj->getSubObj(&pSubComObj);
pSubComObj->doSomeThing();

Thanks,
Bingle

Working with Activex components

Hi,

I have found the module through an entry of mine from Stackoverflow.

I'm trying to make ping requests with nodejs without forking any new processes (ping.exe or cscript.exe).

As there are no raw sockets modules for nodejs, I want to make use of an Activex component for that which is: http://www.activexperts.com/activsocket/objects/icmp/

Can I make this work with node-win32ole?

A simple ASP code I use for the component is as below:

Query = "www.google.com"

set Ping1 = Server.CreateObject("Dart.1")    
set Reply = Ping1.Echo(Query)

if Err = 0 then
    dim Result
    if Reply.Error = 0 then
        Result = "Result for " & Reply.RemoteName & "(" & Reply.RemoteAddress & "): " & Reply.ElapsedTime & " milliseconds"
    else
        Result = "Result for " & Reply.RemoteName & "(" & Reply.RemoteAddress & "): Error #" & Reply.Error & "<br>" & Reply.ErrorDescription
    end if
else
    Result = "There was an error:<br>" & Err.Number & " " & Err.Description
end if

I would appreciate any guidance on using it with node-win32ole.

npm install produces errors

I've run npm install win32ole and got the following:

npm WARN engine [email protected]: wanted: {"node":">= 0.8.18 && < 0.9.0"} (current: {"node":"0.10.36","npm":"1.4.28"})
\
> [email protected] install C:\Temp\node_modules\win32ole\node_modules\ref
> node-gyp rebuild

C:\Temp\node_modules\win32ole\node_modules\ref {git}
{lamb} node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
VCBUILD : error : project file 'C:\Temp\node_modules\win32ole\node_modules\ref\build\binding.vcproj' was not found or  not a valid project file. [C:\Temp\node_modules\win32ole\node_modules\ref\build\binding.sln]
gyp ERR! build error
gyp ERR! stack Error: `C:\windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:820:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Temp\node_modules\win32ole\node_modules\ref
gyp ERR! node -v v0.10.36
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok

> [email protected] install C:\Temp\node_modules\win32ole\node_modules\ref-struct\node_modules\ref
> node-gyp rebuild

C:\Temp\node_modules\win32ole\node_modules\ref-struct\node_modules\ref {git}
{lamb} node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
VCBUILD : error : project file 'C:\Temp\node_modules\win32ole\node_modules\ref-struct\node_modules\ref\build\binding. vcproj' was not found or not a valid project file. [C:\Temp\node_modules\win32ole\node_modules\ref-struct\node_module s\ref\build\binding.sln]
gyp ERR! build error
gyp ERR! stack Error: `C:\windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:820:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Temp\node_modules\win32ole\node_modules\ref-struct\node_modules\ref
gyp ERR! node -v v0.10.36
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the ref package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls ref
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "win32ole"
npm ERR! cwd C:\Temp
npm ERR! node -v v0.10.36
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0
So I did this instead:

```
git clone git://github.com/idobatter/node-win32ole.git
cd node-win32ole
node-gyp configure
node-gyp build
```

This resulted with:

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info spawn C:\windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64' ]
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
VCBUILD : error Message:  [C:\GitTemp\node-win32ole\build\binding.sln]
VCBUILD : System error : -2147154687. [C:\GitTemp\node-win32ole\build\binding.s
ln]
gyp ERR! build error
gyp ERR! stack Error: `C:\windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\vitaly\AppData\Roaming\npm\n
ode_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:
12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Users\\vitaly\\AppData\\Roaming\\npm\\node_modules\
\node-gyp\\bin\\node-gyp.js" "build"
gyp ERR! cwd C:\GitTemp\node-win32ole
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok

Events/Callbacks

This is a really nice module. Thanks for all the hard work.

It works well, the only thing i could not find yet is how to handle callbacks or events raised by a COM component. Is that supported ?

Error working with outlook date/time properties

I am having trouble accessing properties such as LastModificationTime, Start and End on the appointment object in outlook. I am getting this error in the console when trying to access the item.Start / item.End

[Date (bug?)]
ASSERT in 00000000 module ..\src\v8variant.cc(91) @node_win32ole::V8Variant::CreateOCVariant: !v->IsUndefined()
error: The operation completed successfully.

I am able to work with the property in the restrict method on items so I think its a valid property.

var items = calendar.Items.restrict("[Start] > '03/10/2013'");

I am looking to access the date as a string or something I can use in JS. Any thoughts?

"npm i win32ole" error.

Hello. I'm making a Discord bot, and I want to use win32ole to emulate ActiveXObject. But I can't install it locally, cuz of this error:

 [email protected] install C:\Users\Professional\Documents\GitHub\alpha-cc\node_modules\win32ole
> node-gyp rebuild


C:\Users\Professional\Documents\GitHub\alpha-cc\node_modules\win32ole>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Users\Professional\Documents\GitHub\alpha-cc\node_modules\win32ole\build\node_win32ole.vcxproj(20,3): error MSB4019:
 The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration
 is correct, and that the file exists on disk.
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Professional\Documents\GitHub\alpha-cc\node_modules\win32ole
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Professional\AppData\Roaming\npm-cache\_logs\2019-10-15T16_19_49_663Z-debug.log

How to solve this? Please help.

normal exception not catched

when com throw exception ,win32ole should throw this exception,but it just dump with

OLE error: [count] -2147352567 [count] = [1](It always seems to be appeared at
that time you mistake calling 'obj.get { ocv->getProp%28%29 }' <-> 'obj.call { ocv->
invoke%28) }'.) IDispatch::Invoke AutoWrap() failed

Fatal error in g:\jenkins\workspace\nodejs-msi\22874dd8\deps\v8\src\api.h, lin

e 297

CHECK(allow_empty_handle || that != 0) failed

node-win32ole - build erros

I'm building node-win32ole addon using node-gyp.
There are many errors.

(configuration)

  • Visual Studio Express 2008
  • Python 2.6

What is the cause of these errors?
Is there any pre-built module?

Compiling...
v8variant.cc
client.cc
force_gc_internal.cc
force_gc_extension.cc
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(86) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(86) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(87) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(87) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(88) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(88) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(89) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(89) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(90) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(90) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(91) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(91) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(92) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(92) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(86) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(86) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(87) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(87) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(88) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(88) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(89) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(89) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(90) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(90) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(91) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(91) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(92) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(92) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(86) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(86) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(87) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(87) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(88) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(88) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(89) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(89) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(90) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(90) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(91) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(91) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(92) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(92) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(86) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(86) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(87) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(87) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(88) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(88) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(89) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(89) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(90) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(90) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(91) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(91) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(92) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\node_win32ole.h(92) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\client.h(10) : error C2039: 'ObjectWrap' : is not a member of 'node'
c:\program files\nodejs\node_modules\node-win32ole\src\client.h(10) : error C2504: 'ObjectWrap' : base class undefined
c:\program files\nodejs\node_modules\node-win32ole\src\client.h(14) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\client.h(14) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\client.h(15) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\client.h(15) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\client.h(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\program files\nodejs\node_modules\node-win32ole\src\client.h(16) : error C2143: syntax error : missing ',' before '&'
c:\program files\nodejs\node_modules\node-win32ole\src\client.h(18) : error C2039: 'ObjectWrap' : is not a member of 'node'
c:\program files\nodejs\node_modules\node-win32ole\src\client.h(18) : error C2614: 'node_win32ole::Client' : illegal member initialization: 'ObjectWrap' is not a base or member
1>C:\Program Files\Microsoft Visual Studio 9.0\vc\include\xlocale(342) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
..\src\force_gc_internal.cc(19) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
..\src\force_gc_internal.cc(19) : error C2143: syntax error : missing ',' before '&'
..\src\force_gc_internal.cc(21) : error C2248: 'v8::HandleScope::HandleScope' : cannot access protected member declared in class 'v8::HandleScope'
C:\Users\Administrator.node-gyp\0.12.7\deps\v8\include\v8.h(816) : see declaration of 'v8::HandleScope::HandleScope'
C:\Users\Administrator.node-gyp\0.12.7\deps\v8\include\v8.h(800) : see declaration of 'v8::HandleScope'
..\src\force_gc_internal.cc(23) : error C2065: 'args' : undeclared identifier
..\src\force_gc_internal.cc(23) : error C2228: left of '.Length' must have class/struct/union
type is ''unknown-type''
...
...
..\src\node_win32ole.cc(87) : error C2227: left of '->GetFunction' must point to class/struct/union/generic type
..\src\node_win32ole.cc(86) : error C3861: 'NewSymbol': identifier not found
..\src\node_win32ole.cc(87) : fatal error C1003: error count exceeds 100; stopping compilation

does not work on node 0.12.0

Got an error like:

module.js:355
Module._extensions[extension](this, filename);
^
Error: The specified procedure could not be found.
appFolder\node_modules\win32ole\build\Release\node_win32ole.node
at Error (native)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object. (appFolder\node_modules\win32ole\lib\win32ole.js:3:3)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)

Its due to changing in node.js modules structure.

build error

gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/node_win32ole/src/node_win32ole.o
In file included from ../src/node_win32ole.cc:9:
../src/node_win32ole.h:86:36: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
Handle Method_version(const Arguments& args);
^~~~~~~~~
v8::internal::Arguments
/Users/i301792/.node-gyp/6.2.0/include/node/v8.h:145:7: note: 'v8::internal::Arguments' declared here
class Arguments;

Impossible to parse XML using MSXML2

Hi

I'm working on a port from JScript asp to Node.js, and in order to be fully compatible with existing code, i need to use MSXML in order to parse XML. I wrote this piece of code :

        var xData = win32ole.client.Dispatch("MSXML2.DOMDocument.6.0");
        xData.async = false;
        if (!xData.loadXML(xmlResult))
            throw Error(xData.parseError.reason);
        var nodes = xData.selectNodes("action/data/" + _schema);
        node = nodes.nextNode();
        while (node != null) {
            entries.push({
                'objectID': node.attributes.getNamedItem('ba:objectID').text,
                'piece': node.selectSingleNode('piece').text,
                'credit': parseFloat(node.selectSingleNode('credit').text),
                'debit': parseFloat(node.selectSingleNode('debit').text),
                'date': node.selectSingleNode('date').text
            });
            node = nodes.nextNode();
        }

But :

  • nodes.nextNode() don't seem to work (it iterates infinitely),
  • node.attributes.getNamedItem displays :
    OLE error: [getNamedItem] -2147352570 [getNamedItem] IDispatch::GetIDsOfNames AutoWrap() failed
  • node.selectSingleNode displays
    OLE error: [selectSingleNode] Called with NULL IDispatch. AutoWrap() failed

Last both raise exception :
[TypeError: node_win32ole::V8Variant::OLEInvoke failed]

I'm not used at all to node.js (this POC is my first NodeJS experiment), but this works in an IIS environnement on the same machine, so i think the problem is with node/win32ole

Can anyone help please ?

Thanks in advance

Implement Array Parameter Use for Objects

I just added this to my nodejs project to test and see if it would be viable for a project that I am working on. It seems like it works well until I need to call a method that includes parameters are are defined as arrays. I'm getting this error:

[Array (not implemented now)]
[TypeError: node_win32ole::V8Variant::OLEInvoke can't access to V8Variant (null
OCVariant)]

Is this project still being worked on? Is this something likely that would be updated in the future?

WMI: Iterate over result with unknown columnset

Hi,

i ty to use win32ole for wmi. I have som difficulties because in the samples the resulting rows are known. But, how can i iterate over a result, and print the values, when i do not know the resulting columns in advance??

For example with a loop like this:

for (var m in wmires){
    for (var i=0;i<wmires[m].length;i++){
    console.log(wmires[m][i]);
    }
 }

But this produces some kind of conversion issues with V8Variant, which i do not understand.

Can you provide an example??

Why node exits without any error messages?

Hello!

I trying to use your great nodejs module in system monitoring daemon and see very strange behavior. Please see working code sample. When I run it without changes node will exits at 1050-1100 step without any error messages. But this sample have infinite loop.

Changes of timeouts in line 10 are not helps. If I uncomment line 25 with console.log of result object - all begins works ok. If I not touch line 25 and comment line 31 - all works ok too.

What is the reason for this strange behavior?

var win32ole = require( 'win32ole' );
var x=0;

var locator = win32ole.client.Dispatch('WbemScripting.SWbemLocator');
var svr = locator.ConnectServer('.', 'root/cimv2'); // . = self PC

function test() {
    wmi_query( [ 'DeviceID', 'FreeSpace', 'Size' ], 'Win32_LogicalDisk', 'Size != Null' );
  x++; console.log( x );
    setTimeout( test, 1 ); // tested values 1, 10, 50, 100 - all buggy
}
test();

function wmi_query( fields, from, where ) {
  var q = 'SELECT ' + fields.join( ',' ) + ' FROM ' + from; if( where !== undefined ) q += ' WHERE ' + where;
  q = svr.ExecQuery( q );
  var count = q.Count;
  var result = [];
  for( var iq = 0; iq < count; iq++ ){
    var item = q.ItemIndex( iq ), obj = {};
    for( var i = 0; i < fields.length; i++ ) { 
       obj[ fields[ i ] ] = wmi_prop( item, fields[ i ] ); 
    }
    result.push( obj );
    //console.log(obj); // 1050-1100 times w/o this
  }
  return( result );
}

function wmi_prop( obj, propertyname ){
  var property = obj[propertyname]; // if remove this, works normally
  return property == null ? 'NULL' : property;
};

Problem installing nodewin32ole

Hi people

I'm getting this error trying to install nodewin32ole.
Running npm install win32ole, follows:

"==========================================================="
C:>npm install win32ole
npm http GET https://registry.npmjs.org/win32ole
npm http 304 https://registry.npmjs.org/win32ole
npm WARN engine [email protected]: wanted: {"node":">= 0.8.18 && < 0.9.0"} (current
: {"node":"v0.10.23","npm":"1.3.17"})
npm http GET https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/ref-struct
npm http GET https://registry.npmjs.org/ref
npm http GET https://registry.npmjs.org/assert
npm http 304 https://registry.npmjs.org/async
npm http 304 https://registry.npmjs.org/ref
npm http 304 https://registry.npmjs.org/ref-struct
npm http 304 https://registry.npmjs.org/assert
npm http GET https://registry.npmjs.org/util/0.10.1
npm http GET https://registry.npmjs.org/debug
npm http GET https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/debug
npm http 304 https://registry.npmjs.org/util/0.10.1
npm http 304 https://registry.npmjs.org/bindings
npm http GET https://registry.npmjs.org/inherits/2.0.1

[email protected] install C:\node_modules\win32ole\node_modules\ref
node-gyp rebuild

C:\node_modules\win32ole\node_modules\ref>node "C:\Archivos de programa\nodejs\n
ode_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" r
ebuild
C:\Documents and Settings\Administrador.node-gyp\0.10.23\deps\v8\include\v8.h(
184): warning C4506: no definition for inline function 'v8::Persistent v8::P
ersistent::New(v8::Handle)' [C:\node_modules\win32ole\node_modules\ref\bu
ild\binding.sln]
LINK : fatal error LNK1181: cannot open input file 'C:\Documents.obj' [C:\node_
modules\win32ole\node_modules\ref\build\binding.sln]
Project : warning PRJ0018: The following environment variables were not found:
[C:\node_modules\win32ole\node_modules\ref\build\binding.sln]
gyp ERR! build error
gyp ERR! stack Error: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Archivos de programa\nodejs\node_m
odules\npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:
12)
gyp ERR! System Windows_NT 5.1.2600
gyp ERR! command "node" "C:\Archivos de programa\nodejs\node_modules\npm\no
de_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\node_modules\win32ole\node_modules\ref
gyp ERR! node -v v0.10.23
gyp ERR! node-gyp -v v0.12.1
gyp ERR! not ok
npm http 304 https://registry.npmjs.org/inherits/2.0.1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the ref package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls ref
npm ERR! There is likely additional logging output above.

npm ERR! System Windows_NT 5.1.2600
npm ERR! command "C:\Archivos de programa\nodejs\node.exe" "C:\Archivos de
programa\nodejs\node_modules\npm\bin\npm-cli.js" "install" "win32ole"
npm ERR! cwd C:
npm ERR! node -v v0.10.23
npm ERR! npm -v 1.3.17
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\npm-debug.log
npm ERR! not ok code 0
C:>
"==========================================================="

Im not sure what it means. Is it a problem with nodejs version??
Some body is experiencing the same issue?
VS 2008 Professional and Python 2.7 is installed on my system.

Help please.

Thanks in advance.
lordBreetai

win32ole processes still running

I've noticed that when using win32ole to access Excel, I still have "EXCEL.EXE" processes showing in Windows Task Manager. It seems that xl.Quit(); doesn't actually close the application. Here is an example of what I'm doing:

var xl = win32ole.client.Dispatch('Excel.Application');
xl.Visible = false;
xl.DisplayAlerts = false;
xl.ScreenUpdating = false;
xl.EnableEvents = false;
var book = xl.Workbooks.Open(filename);
book.Saved = true;
xl.Workbooks.Close();
xl.Quit();

I've tried forcing garbage collection as well with no change in behavior. Also, after two cycles of opening and closing the excel workbook, I get the following error on the third and all subsequent attempts:

OLE error: [Open] -2147352570 [Open] IDispatch::GetIDsOfNames AutoWrap() failed

Implement _FlagAsMethod (like python's win32com)

Hi,
Getting this error:

(It always seems to be appeared at that time you mistake calling 
'obj.get { ocv->getProp() }' <-> 'obj.call { ocv->invoke() }'.) 
IDispatch::Invoke AutoWrap() failed

Now, the python module win32com as found in the pywin32 package seems to solve it.

import win32com.client

max = win32com.client.Dispatch("MAX.Application.16")
max._FlagAsMethod("DoExecute")
hr = max.DoExecute( someCommand )

Would it be possible to implement something like that?
ie: forcing 'call' over 'get' ?

Or does node-win32ole already have a similar thing?

Thanks,
Tim

Question on installing

Trying to run the sample.

I had a couple of problems getting the node-win32ole installed:
When I run npm install win32ole I get:
....
Creating library E:_vault\node_win32ole\test\node_modules\win32ole\build
Release\node_win32ole.lib and object E:_vault\node_win32ole\test\node_module
s\win32ole\build\Release\node_win32ole.exp
client.obj : error LNK2001: unresolved external symbol __imp__CoCreateInstance@
20 [E:_vault\node_win32ole\test\node_modules\win32ole\build\node_win32ole.vcxp
roj]
client.obj : error LNK2001: unresolved external symbol __imp__CLSIDFromProgID@8
[E:_vault\node_win32ole\test\node_modules\win32ole\build\node_win32ole.vcxpro
j]
v8variant.obj : error LNK2001: unresolved external symbol __imp__VariantTimeToS
ystemTime@12 [E:_vault\node_win32ole\test\node_modules\win32ole\build\node_win
32ole.vcxproj]
v8variant.obj : error LNK2001: unresolved external symbol __imp__SystemTimeToVa
riantTime@8 [E:_vault\node_win32ole\test\node_modules\win32ole\build\node_win3
2ole.vcxproj]
ole32core.obj : error LNK2001: unresolved external symbol __imp__SysAllocString
@4 [E:_vault\node_win32ole\test\node_modules\win32ole\build\node_win32ole.vcxp
roj]
ole32core.obj : error LNK2001: unresolved external symbol __imp__SysStringLen@4
[E:_vault\node_win32ole\test\node_modules\win32ole\build\node_win32ole.vcxpro
j]
ole32core.obj : error LNK2001: unresolved external symbol __imp__VariantClear@4
[E:_vault\node_win32ole\test\node_modules\win32ole\build\node_win32ole.vcxpro
j]
ole32core.obj : error LNK2001: unresolved external symbol __imp__CoUninitialize
@0 [E:_vault\node_win32ole\test\node_modules\win32ole\build\node_win32ole.vcxp
roj]
ole32core.obj : error LNK2001: unresolved external symbol __imp__MessageBoxW@16
[E:_vault\node_win32ole\test\node_modules\win32ole\build\node_win32ole.vcxpro
j]
ole32core.obj : error LNK2001: unresolved external symbol __imp__VariantCopy@8
[E:_vault\node_win32ole\test\node_modules\win32ole\build\node_win32ole.vcxproj
]
ole32core.obj : error LNK2001: unresolved external symbol __imp__VariantInit@4
[E:_vault\node_win32ole\test\node_modules\win32ole\build\node_win32ole.vcxproj
]
ole32core.obj : error LNK2001: unresolved external symbol __imp__CoInitialize@4
[E:_vault\node_win32ole\test\node_modules\win32ole\build\node_win32ole.vcxpro
j]
ole32core.obj : error LNK2001: unresolved external symbol __imp__SysFreeString@
4 [E:_vault\node_win32ole\test\node_modules\win32ole\build\node_win32ole.vcxpr
oj]
E:_vault\node_win32ole\test\node_modules\win32ole\build\Release\node_win32ole.
node : fatal error LNK1120: 13 unresolved externals [E:_vault\node_win32ole\te
st\node_modules\win32ole\build\node_win32ole.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe failed with exit code: 1
...
Apparently that is caused by ole32.lib, oleaut32.lib missing from the list of libraries used by linker. I didn't know how to get around that so I followed the instructions under "To obtain and build the bindings:" and that appeared to work.

Can you tell me how to resolve the issue with the install?

Couldn't build. Can you share build zip?

Can not build with VS#2015, is it possible to get zip (only build) file that i can put directly into node_modules to be used in nodejs app?

C:\WORK\win32ole\node-win32ole>node-gyp build
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64' ]
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe".
To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visua
l Studio 2005 or 3) add the location of the component to the system path if it
is installed elsewhere. [C:\WORK\win32ole\node-win32ole\build\binding.sln]
gyp ERR! build error
gyp ERR! stack Error: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\rajil\AppData\Roaming\npm\no
de_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_proces
s.js:200:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\rajil\AppDat
a\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" "build"
gyp ERR! cwd C:\WORK\win32ole\node-win32ole
gyp ERR! node -v v4.2.2
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok

Chokes on variants which are null

node-win32ole exits with an error when trying to retrieve a value which is null. I can only reproduce this problem with ADO, for which being able to use null values is pretty critical.

Example:

var win32ole = require('win32ole');
var fs = require('fs');

// Create a simple database (unless we already have)

var sFolder = __dirname + "/TextFileDb"
var sFilename = __dirname + "/TextFileDb/myTable.csv"

if (fs.existsSync(sFolder) == false) fs.mkdirSync(sFolder);
if (fs.existsSync(sFilename) == false) fs.writeFileSync(sFilename, "description,thing\r\nHere is a null value:,");

// Open our database

var sConnectionString = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + sFolder + ';' +
                        'Extended Properties="text;HDR=Yes;FMT=Delimited"';

var db = win32ole.client.Dispatch('ADODB.Connection');
db.Open(sConnectionString);

var rs = win32ole.client.Dispatch('ADODB.Recordset');
rs.Open("select * from myTable.csv", db);

// Attempt to print the contents of our database

rs.MoveFirst();

while(rs.EOF == false)
{
    console.log(rs.Fields(0).Value.toString());
    console.log(rs.Fields(1).Value.toString());

    rs.MoveNext();
}

rs.Close();
db.Close();

Output:

Here is a null value:
ASSERT in 00000000 module ..\src\v8variant.cc(93) @node_win32ole::V8Variant::Cre
ateOCVariant: !v->IsNull()
error: The operation completed successfully.

D:\git\nodejsplay\test.js:31
    console.log(rs.Fields(1).Value.toString());
                                   ^
TypeError: node_win32ole::V8Variant::OLEFlushCarryOver can't access to V8Variant
 (null OCVariant)
    at Object.<anonymous> (D:\git\nodejsplay\test.js:31:36)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

For reference here is some equivalent PHP code:

<?php
// Skip database creation as the node.js script has already done that successfully

// Open our database

$sConnectionString = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=./TextFileDb;' .
                     'Extended Properties="text;HDR=Yes;FMT=Delimited"';

$db = new COM('ADODB.Connection');
$db->Open($sConnectionString);

$rs = new COM('ADODB.Recordset');
$rs->Open("select * from myTable.csv", $db);

// Attempt to print the contents of our database

$rs->MoveFirst();

while($rs->EOF == false)
{
    echo($rs->Fields(0)->Value . "\r\n");
    echo($rs->Fields(1)->Value . "\r\n");

    $rs->MoveNext();
}

$rs->Close();
$db->Close();
?>

Which produces the expected output:

Here is a null value:

ppt转pdf

不支持ExportAsFixedFormat,如何添加该方法

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.