I have to implement the VinPower application. They offer a Java version, a C dll and an ActiveX dll, if anyone has an idea on where I could begin, I'd appreciate it.
First step would be to put the VinPOWER Jar file into your lib directory, then restart the server.(Or, you can put the file in a different directory and then add the path in CF Administrator)
Then to use it... well, here is their Java sample in CFML:
<cfset vp = createObject("java","com.pki.vp4j.VinPower") />
<cfset rc = vp.decodeVIN("JTEDP21A650046919") />
<cfif rc>
<cfoutput>#vp.getAsXML()#</cfoutput>
</cfif>
Give that a try and see what you get?
A quick Google search shows that there is Vinpower and there is VinPOWER. To which one are you referring?
When you say "implement", are you looking at writing your own library that does the same thing as an existing product? Or did you mean to say "integrate" where you need to use a third party library within your existing project?
If your goal is to integrate, and the vendor supplies different versions of the library for different interfaces, I would pick the one that would be easiest to integrate with your existing project. For example, if your code is already in Java then I would pick the Java version of their library. If your code is in Visual Basic, then you might be best off with the ActiveX dll.
Related
I am currently working on a C++ gui application. The application uses the Python/C API to call some python scripts. The scripts are located in the solution directory, and I call them by simply providing the path. This is currently working fine while debugging the application or even running the generated .exe file, but I am wondering how this could work if I want to release and distribute the application onto a different computer for someone to use. How can these scripts be deployed with the application?
I also have a .ttf font file with the same situation. How can this resource file be deployed with the application?
In other words, I want to deploy/release a C++ application with the scripts and resource files.
FYI: the C++ application is a Visual Studio project.
Thanks for the help in advance, and let me know if any more information is needed!
Update:
I just wanted to clear up the way my project is working currently:
PyObject* pArgs = PyTuple_New(5); // I setup the arguments the python function needs
PyImport_ImportModule("requests"); // imports...
// make python call
PyObject* pResult = PyObject_CallObject(pFunc, pArgs);
So this is (for the most part) how I call the scripts with the C++ source code. The scripts are located in a folder that is located in the solution directory.
I hope this explains my problem a little better.
Update:
Just another little update... Using some answers to other similar questions got me to the following point:
I need to obtain a python library, compile and link it with my C++ application, and then bundle the dependencies with the application (How to distribute C++ application which calls Python?)
So I guess my question is now shifting to how I would be able to get this done. What are the specific steps to do this? I also got a link (https://docs.python.org/3.5/using/windows.html#embedded-distribution) to an embedded distribution of a python environment (maybe this should somehow be used?). Also, I am able to statically link python into the application. I just don't know how to bundle and deploy the scripts I created and use in the application.
PyImport_ImportModule("requests")
The parameter is "requests".
Put the py file aside exe file when distributing.
So, you need to make sure that the C++ application can still access the python libraries when its released and those libraries/dependencies arent necessarily available on other systems.
You'll need to, like another commenter suggested, use one of the importing modules utilities, like PyImport_ImportModule("library name").
You can see these utilities here: https://docs.python.org/3/c-api/import.html
You'll also need to either
Put the libraries that you want with the exe (in the same directory) or
put them in the system environment path ( which is probably less straightforward).
Hope that helps and that I understood you're question correctly.
I am trying to register a CPP library into COM during the Msi installation.
I have searched a lot and found many solutions in here, but nothing is working in my code. I don't know is there any direct method for this. I have tried using Custom Action with direct ExeCommand and with a batch script.
Here is the code with batch script.
<SetProperty Id="Register" Value=""[INSTALLDIR]Scripts\Register.bat"" After="CostFinalize"/>
<CustomAction Id="Register" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="check" Impersonate="no"/>
<SetProperty Id="Unregister" Value=""[INSTALLDIR]Scripts\UnRegister.bat"" After="CostFinalize"/>
<CustomAction Id="Unregister" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="check" Impersonate="no"/>
Using this code, installation does not show any error, but dll is not getting registered. After installation if I ran the batch script separately then it gets registered.
Register.bat
cd "C:\Windows\System32"
regsvr32 "C:\Program Files (x86)\ABC\Abc.dll"
ping -n 15 127.0.0.1 >nul:
Unregister.bat
cd "C:\Windows\System32"
regsvr32 /u "C:\Program Files (x86)\ABC\Abc.dll"
ping -n 15 127.0.0.1 >nul:
With Custom Action with ExeCommand it shows error like some dll dependency missing.
ExeCommand code is given below.
<CustomAction Id="Register" Directory="INSTALLDIR" Execute="deferred" Impersonate="no"
ExeCommand="[WindowsFolder]System32\regsvr32 "[INSTALLDIR]Abc.dll"" Return="check" />
<CustomAction Id="Unregister" Directory="INSTALLDIR" Execute="deferred" Impersonate="no"
ExeCommand="[WindowsFolder]System32\regsvr32 /u "[INSTALLDIR]Abc.dll"" Return="check" />
And InstallSequencefor both the cases is given below.
<InstallExecuteSequence>
<Custom Action="Register" Before="InstallFinalize" >NOT Installed</Custom>
<Custom Action="Unregister" Before="RemoveFiles">Installed AND NOT UPGRADINGPRODUCTCODE</Custom>
</InstallExecuteSequence>
In both the case I think it is running with elevated privileges.
This is the error I get most of the time.
Edit
Dependency walker view of the dll is shown below.
Also I am adding the heat command I used. I have added this to prebuild event to generate the component. After that added this component in product file.
call "$(WIX)bin\heat.exe" file "dllPath\Abc.dll" -dr "INSTALLDIR" -srd -gg -sfrag -suid -out "$(SolutionDir)Installer\ComRegisterComponent.wxs"
And the generated file is look like this.
<Fragment>
<DirectoryRef Id="INSTALLDIR">
<Component Id="Abc.dll" Guid="*">
<File Id="Abc.dll" KeyPath="yes" Source="SourceDir\Abc.dll" />
</Component>
</DirectoryRef>
</Fragment>
Here this SourceDir path is confusing me.I have added the exact path in heat command even then it generates this SourceDir.
Short, Summary Answer
You need to stop using batch files and custom actions for COM registration (unreliable) and rather extract the COM registration information using the heat.exe tool from the WiX toolkit to add the COM registration to your MSI database at compile time.
There are some complications for 64-bit binaries, see details below. Fortunately it looks like you are dealing with a 32-bit component based on your installation directory shown above.
In this particular case it helped to run heat.exe on the COM file after deployment when all dependencies were "in place" for the COM file to load properly. There is a lot of "debugging communication" in these answers - I'll leave it all in place for the future, but try this simple solution first. And perhaps try the new dependency tool "Dependencies.exe" described below.
Long, Detailed Answer
Before I try to answer the question (which seems to revolve around missing dependencies or something weird being done in your batch file), I want to clear up a few things for you with regards to best practice for COM registration.
Note: the screenshot seems to indicate something weird going on in your batch file, but missing dependencies could still be an issue.
Self-registration Considered Harmful
Self-registration should not be used to register COM files. Here is a description of why this is the case: MSI register dll - Self-Registration considered harmful. There is good news, however, doing things as intended via built-in MSI mechanisms will be both easier and more reliable once you set it up properly.
There is a way to self-register files during installation without using custom actions like you are trying to do (the SelfReg table). Custom actions are very hard to get working correctly, but you should not use the built-in mechanism to run self-registration either (as explained in detail in the linked answer above)
Rather than using custom actions or the SelfReg table, COM registration information should be extracted from your COM files at compilation time - in other words when you compile your MSI file from your WiX source files. The extracted registry data should be used to populate the family of MSI data tables designed to reliably register and unregister the COM file during installation and uninstallation respectively.
WiX: The "heat.exe" Command Line Tool
Understanding the intricate details of this process is not necessary - all you need to know is what tools to use. WiX provides the "heat.exe" tool for this purpose. It is essentially a "harvester" tool capable of generating valid WiX XML source files for several purposes - one of which is COM extraction. It also supports traversing directories in general - generating WiX source files which can install the files encountered during traversal. It is essentially a very quick way to make an MSI package once you know how to use it.
Dependency Walker
So we have established that you should take the time to learn how to use heat.exe to generate the WiX source necessary to register the COM file properly. however, there is one more problem: the missing dependencies.
For a COM file to be able to self-register - or for you to be able to successfully extract the COM registry data using heat.exe - the COM file must be able to load correctly. For this to be possible all dll dependencies must be available on the system in question in an accessible location.
Get yourself a copy of Dependency Walker and use it to scan your COM file for what files it depends on. Here is an example of a COM file which fails to load because it cannot find MMUtilities.dll:
You will most likely find something similar wrong with your dll (or whatever file type it is, for example OCX) when it is run from your setup's installation location. The required dependency files can not be found by regsvr32.exe and the registration process fails.
There are some reported missing dependencies that are not important - I guess this has to do with the age of the Dependency Walker tool - it hasn't been updated recently as far as I know. Look for a file you recognize as either your own dependency file or a core system file as opposed to very long dll names of files you have never heard of. Keep in mind that some dlls have dependency language dlls that are required for loading. For example MMUtilities.dll needs MmUtilitiesEnglish.dll or another language dll present in the same folder to be able to load correctly.
Some sample false positive dependencies for the above file: API-MS-WIN-CORE-RTLSUPPORT-L1-1-0.DLL, API-MS-WIN-CORE-PROCESSTHREADS-L1-1-0.DLL, API-MS-WIN-CORE-REGISTRY-L1-1-0.DLL, etc... There were many. I believe, but I am not sure, that the root cause of these false positives centers around problems with side-by-side components installed to the WinSxS folder, but that is a whole other discussion - just mentioning it.
UPDATE: I just checked this again and most of the false positive dependencies seen above are apparently API-sets - a Windows feature introduced long after Dependency Walker was created, and hence not handled correctly by the tool.
As the linked answer indicates (do read it, link above), there is now also a rewrite of Dependency Walker in C# called "Dependencies", available here: https://github.com/lucasg/Dependencies (untested by me at time of writing, will test shortly).
Also quick mention: if you have an executable to check (as opposed to a dll, ocx, etc...), you can launch it via the Profile => Start Profiling... menu entry and you will then also see "hidden run-time dependencies" not specified in the binary import table (where dependencies / imports are specified). You need to really exercise the application using all features in all dialogs to be sure to get all such dependencies.
The dependency walker web page calls these hidden dependencies explicit dependencies (a dynamic or run-time dependency) and system hook dependencies (injected dependencies). See the link just above for more details.
Heat.exe Extraction
Once you have determined what files are missing for making your WiX heat.exe extraction work, you can put the files in question "next to" your COM dll so they are found during its loading. You can test run using regsvr32.exe to see if registration completes correctly. There should be no error messages when you run registration manually like this. Remember to run registration from an elevated command prompt.
Several other stackoverflow answers explain how to use heat.exe - I haven't used it in a long time: How to run heat.exe and register a dll in wix. Here is the official documentation for heat.exe from the WiX guys themselves. It can be a somewhat intimidating tool - it has a lot of features.
In its simplest form (for normal 32-bit COM files with all dependencies available in the path or local folder), you can run this heat.exe command line to generate an output WiX source file called YourFileName.wxs with all the required COM registry data.
heat.exe file YourFileName.ocx -o YourFileName.wxs
I wrote an answer several years ago showing how to incorporate the exported WiX registry data into your main WiX source: How to Reference a Heat Output(wxs) in Wix (Command Line). I believe this is an accurate description of the procedure, but for some reason someone down-voted the answer. Please give it a go and see if it works for you.
Important!: heat.exe does not yet correctly process 64-bit COM binaries (December, 2017).
I have been informed that the WiX Expansion Pack (not free) handles 64-bit binaries and provides several other features.
I suppose I can link to it (I am not affiliated with FireGiant): https://www.firegiant.com/wix/wep-documentation/harvesting/. Somehow people need to know about these things, but I am not sure about the the stackoverflow etiquette of linking.
Are your binaries 64-bit? (it doesn't look that way from your installation folder, but I add this for others who might find it). For a 64-bit component I guess we have come full circle and have to advise you to either use the above expansion pack feature or just try to set the file to self-register as described here. I hate this self-register "solution", but I can't think of any other quick fixes at the moment (none that I would recommend anyway). I will check again. Make sure to check the latest WiX release to see if the 64-bit problem has been fixed before going for this "self-registration fix". It is at least better than trying to register using custom actions and batch files (which should never be attempted - there are so many potential problems relating to MSI's complex custom action sequencing, impersonation / elevation, conditioning,installation modes with silent and interactive, not to mention the potential interference from security software, and the list goes on).
Some links:
How do you register a Win32 COM DLL file in WiX 3?
Cannot register DLL using WiX
Use wix to perform function of REGSVR32
Heat.exe Cannot Harvest TypeLib Info from a 64-bit COM DLL
Heat.exe: 64-bit .dll fails to be converted to a 64-bit .msi
Just adding another answer with information on how to use procmon.exe in an efficient manner to debug missing dependencies during self-registration using regsvr32.exe.
Essentially you should set an include filter for what events you want to monitor and record, otherwise you get an almighty list of irrellevant events listed and it is hard to find what you need in the sea of useless information:
To limited the captured process information to what you need, just go to Filter => Filter...
Set the left drop down to Process Name and then the second column to is and finally type in regsvr32.exe in the right box as illustrated above in the picture.
Crucially set the rightmost box to Include. Then press OK.
All unnecessary events should now be suppressed and only regsvr32.exe events are displayed (when you get to running it).
Run regsvr32.exe the normal way and look for "NAME NOT FOUND" entries (or similar) in the list.
In the illustration below MMUtilities.dll can not be found. In other words it is a missing dependency.
And please note that you can include / exclude events of a certain type by clicking the buttons illustrated below on and off. Registry events, file system events, network activity, process and tread activity, profiling events. This can greatly reduce the "noise" you have to deal with in the list.
The other way to debug missing dependencies during self-registration is to use Dependency Walker as illustrated in my other answer in this "thread" or question or whatever to call it. Generally I find Dependency Walker to be the quicker option, but ProcMon is perhaps better overall - unless you are debugging an EXE file, then Dependency Walker has the superior Profile feature (Profile => Start Profiling...).
The idea is not to use a bat file for registering the dll. Let Windows installer/WiX do it for you. This has been answered in the past also here.
Can a Windows Installer perform logic like a normal application?
For example: I am creating an installer that installs plugin files to a 3rd Party Application's directory on the C drive. But the destination directory will be different if the user has an old version of the 3rd Party Application.
So the installer needs to determine what version of the 3rd Party Application is on the C drive. If its the new version I install the plugin files to C://Program Files//3rdPartyApplication// and if its the old I install to C://3rdPartyApplication//
So can a windows installer perform logic and if not can it run batch files that can do this?
An "installer" is just a regular application designed to unpack its contents onto a persons hard drive, and possibly perform actions like registry modifications.
If you use a installer like install shield for example you will have to look at that installer documentation to see what it can do. Most installer applications have some sort of area to create custom scripts.
You could also build your own, it is really not very hard.
Yes, installer can perform logic just like regular application. From this point of view, an installer is a regular application.
How you program installer logic depends on which installer suite you use. For detecting whether an application exists in C:\Program Files\3rdPartyApplication or in C:\3rdPartyApplication, you can use FileSearch element of WiX Toolset, look through Windows Installer documentation: Searching for Existing Applications, Files, Registry Entries or .ini File Entries.
More sophisticated logic can be implemented by custom actions. [Custom Actions}(http://msdn.microsoft.com/en-us/library/aa368066.aspx) can be written in JScript, VBScript, C/C++ (DLL or EXE; yet the EXE can't communicate to the Windows Installer session).
I'd like to give a different perspective. Windows Installer is a declarative domain specific programming language. It is not a Turing complete general purpose programming language. It is not intended to be just like any other application. It can be extended with custom actions written in general purpose programming languages such as C++/C# but it should stil follow the same declarative approach where you seperate the "how" to do something from the "what" to do.
Now to answer the second part of your question. Windows Installer has built in searching capabilities. Read the MSDN topics on the AppSearch standard action and related tables (AppSearch, Signature, DrLocator, CompLocator, RegLocator ) You can also put conditions on components and you can set directory destinations dynamically so yes, there are ways of doing what you want to do.
It would require much more information to explain exactly how to do it.
Yes, Windows Installer can perform logic like a normal application.
You can use the WiX Toolset, as suggested by Alexey to get the job done.
You can use the FileSearch element ( http://wix.sourceforge.net/manual-wix3/wix_xsd_filesearch.htm) to check for the existence of files or the RegistrySearch element ( http://wix.sourceforge.net/manual-wix2/wix_xsd_registrysearch.htm) in case you want to check using a registry key.
Alternatively, if the search isn't as simple as checking for a file or a registry, a Custom Action would let you write managed or unmanaged code (according to your preference) to check which version of the 3rd party application is installed.
On the basis of the result of your search, you can, at run-time, change your install directory. A Type 35 Custom Action would let you change the install directory:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa368093%28v=vs.85%29.aspx
Information about what I want to do:
-read in a few integer variables from a text file that will be located on a dropbox public folder.
-the variables will be used to trigger some if statements thus controlling my application remotely if I need to have it do something ( I would just save the variable I need to that text file and my program with would read from it every 5 seconds would see it and perform the required actions).
-this is a console application which is being built and compiled in visual studio 2010 on windows 7. The software will also be running on a win7 computer.
I need help with:
I already have read on using a library called libcurl. The problem is that I do not know how to link this library with my project in vs2010. Detailed instructions on how to do this on vs 2010 would be very helpful.
OR
if you can think of a better and easier way to accomplish what I need done, offer some advice and direction
It sounds like you're a novice, is that correct? If not then apologies for stating the obvious.
To use your compiled DLL in your application you need to 'add a reference' to it. You can do this by adding what is called a binary reference, where you simply tell visual studio where to find the dll. Or you can add a project reference if the project which is producing the dll is within the same solution. The best approach is to use something called nuget. It's a visual studio extension which automates the adding of binary references available from a public repository.
I have just done a search for libcurl on nuget.org and drew a blank. As I am unfamiliar with this library you may have better luck finding a nuget package as you will be a le to search using better terms that I did (curl and libcurl)
Whatever approach you take, just right-click on the project in which you want to use libcurl within the solution explorer and you should find an add reference option in the menu.
I've done app by c++ . It's serial port programming/win app.
It's got many files and I would like to make an exe file(setup file to install on client's pc) for delivering thru customers.
I did many research and as far as i see i couldnt.
Any way to do that ?
Would be appreciated.
You need to create a setup project and add it to your solution.
EDIT
You may also like to check this and this links.
So after the comments, I'm pretty sure what you really want is to build an installer for your application which will package up your built executables with all it necessary libraries and what not, so that you can deliver a single file to your customers and have them install it.
A basic way is the way a lot of open source/free software projects do it - supply an archive/zip/whatever file that the user downloads and unzips on their own machine. I don't really recommend this way unless your users are all technical.
At a previous company we InnoSetup, which is really nice, easy to learn, and free.
nsis is another option. http://nsis.sourceforge.net/Main_Page . It can create windows installers and is script based.