microsoft / nodejs-guidelines

Tips, tricks, and resources for working with Node.js, and the start of an ongoing conversation on how we can improve the Node.js experience on Microsoft platforms.
2.49k stars 280 forks source link

call c++ dll by using loadlibrary #92

Open ricky-yi opened 5 years ago

ricky-yi commented 5 years ago

Everything works when the environment setup with option I.

And because my dev machine can't connect to Internet, I use option 2 to setup node-gyp, it works ok but loading c++ dll with loadlibray, compile succeed, but run error by returning NULL handle.

are there any configure options should be set in option 2.

Thanks.

Following are the 2 options:

Environment setup and configuration: •Option 1: Install all the required tools and configurations using Microsoft's windows-build-tools by running npm install -g windows-build-tools from an elevated PowerShell (run as Administrator). •Option 2: Install dependencies and configuration manually i.Install Visual C++ Build Environment: Visual Studio Build Tools (using "Visual C++ build tools" workload) or Visual Studio 2017 Community (using the "Desktop development with C++" workload) ii.Install Python 2.7 (v3.x.x is not supported), and run npm config set python python2.7 iii.Launch cmd, npm config set msvs_version 2017

ricky-yi commented 5 years ago

my code: HMODULE hdll = LoadLibrayA("xxx.dll"); if(!hdll) { cout << "error: " << GetLastError() << endl;

when running, hdll is null and error code is 0 which means run successfully.

mcastillo86 commented 5 years ago

I'm having the exact same problem. Can someone figure out what the issue is please?