I have an installer (made with Advanced Installer). I have an application that has to interact with it, but I don't know how to find the MSIHANDLE of that installation. I looked in the Microsoft Reference but I haven't found anything helpful for my problem.
Any help please?
The MSI handle is not available to out of process code. You'd need to write a custom action that could host some type of RPC mechanism that your application could then interact with. This is basically how Windows Installer XML's (Wix) Deployment Tools Foundation (DTF) works. It allows you to write custom actions using C# that gets wrapped with a C++ host. The C++ host uses RunDLL32 to execute the managed code out of process ( so that it doesn't tattoo the msiexec process with a CLR version ) and then an IPC tunnel is created between the two.
In your C# there is an interop library that marshalls calls across the IPC tunnel where the C++ code then calls the MSI API and returns the results.
Related
I've written a console program that "does stuff" - mainly using boost. How do I convert it to a Windows Service?
What should I know about Windows Services beforehand?
There's a good example on how to set up a minimal service on MSDN. See the parts about writing the main function, entry point and also the example code.
Once you've got a windows service built and running, you'll discover the next major gotcha: it's a pain to debug. There's no terminal (and hence no stdout/stderr) and as soon as you try to run the executable it actually launches the service then returns to you.
One trick I've found very useful is to add a -foreground option to your app so that if you run with that flag then it bypasses the service starter code and instead runs like a regular console app, which makes it vastly easier to debug. In VS.Net set up the debugging options to invoke with that flag.
There's a really good example on msdn here
It's a boiler plate C++ service project that has self install/uninstall functionality and logs service start and stop events to the windows event log. It can be stopped and started through the services app (snapin) like other services. You may want to initially give it LocalSystem rights to see it working , as on xp at least it doesn't have enough rights to start with the project provided rights of LocalService. The Visual Studio 2008 project otherwise runs out of the box despite the downloaded instructions implying otherwise.
A bit late but I hope this helps someone else.
You might be able to 'wrap it' using this tool from CodeProject:
http://www.codeproject.com/KB/system/xyntservice.aspx
Worth a look.
The simplest solution might be to create a new Windows Service project in Visual Studio and copy across your code to the new project.
If you refactor your code so that you've split the UI (in this case the console) from the logic you could create a library that does the work and then call that from both the Console project and the Service Project.
You can configure an application to run as a service by using the Srvany tool, which is a part of the Windows Server 2003 Resource Kit Tools.
Srvany allows only one service at same time. So I write my srvany (sFany) to make nginx and php-cgi run as windows service together. Here is the source https://github.com/stxh/sFany
I'm porting some Qt Windows/VC++ code to Linux/GCC. The application can add it's own shortcut to the Windows Autostart folder so the application starts after login.
I want to do the same in Linux. I'm using Kubuntu 15.10 but the solution should work for virtually all (or at least most) Linux variants out there. And it should work without super user rights (or it should request the rights automatically).
I searched the web and found two solutions:
Add a desktop entry file to $HOME/.config/autostart
Add a symbolic link to /etc/init.d/
Will they both work in all Linux distributions? What are the differences? Which is to be preferred?
Also I would like to know if I should do that by programmatically running a shell command or if there is some native API I could use in C/C++ (including easy error detection).
I have put project in GitHub for managing auto-start feature in different OS. It's written in Qt.
Please check it and let me know if you have any problem using it:
https://github.com/b00f/qautostart
You can add application in various ways.
Via linux init system. For newest linux OS systemd is a standard. In this case your need to create systemd unit for your application
Via desktop manager, such as gnome, kde and possible others. In this case you need also create specification for autostarting your app.
Via bash files
I think, prefered way via systemd unit, because now this is standard way for starting process at boot time and for special user, if need.
I need to debug JNI issue of a team member. The problem is in a Java app interfacing a USB connected hardware using JNI. He mentions that JNI functions implemented in a C++ dll are not getting called by Java app. Also he specifically mentioned that it is a not an unsatisified link error problem, which was the first thing I would suspect.
The strange thing is that the Java App works fine on his development system and the JNI calls are being made properly. However on the target machine of the QA team, the Java app does not seem to work.
The DLL (32-bit) was generated using VS2010 and the target machine was WinXP/Win 7 32-bit system. I would rule out DLL method signature issue since DLL was recognised on the development system. As mentioned, it was not link issue.
What could be the issue in JNI methods not getting invoked at all? Could this be a problem with redistributables? How to debug (using JVM options) and ascertain the problem?
Standard debugging procedure:
set breakpoint in Java
run to breakpoint
attach debugger to java executable (visual studio attach by process ID)
set breakpoint in JNI.
continue Java program.
Does any body know how can I use MS_MPI in my VC++ MFC project?
I already have a big MFC project and I only want to use parallel processing in a part of it with MPI.
(I know how to use MPI in a separate code, but I don't know how to integrate it with my VC++ MFC project)
Not sure about MS_MPI, but you wanna look at MPICH2 Windows documentation guide at the url at the bottom.
9.3 MPI apps with GUI
Many users on Windows machines want to build GUI apps that are also MPI
applications. This is completely acceptable as long as the application follows
the rules of MPI. MPI Init must be called before any other MPI function
and it needs to be called soon after each process starts. The processes must
be started with mpiexec but they are not required to be console applications.
The one catch is that MPI applications are hidden from view so any
Windows that a user application brings up will not be able to be seen.
mpiexec has an option to allow the MPI processes on the local machine
to be able to bring up GUIs. Add -localroot to the mpiexec command to
enable this capability. But even with this option, all GUIs from processes
on remote machines will be hidden.
So the only GUI application that MPICH2 cannot handle by default
would be a video-wall type application. But this can be done by running
smpd.exe by hand on each machine instead of installing it as a service. Log
on to each machine and run “smpd.exe -stop” to stop the service and then
run “smpd.exe -d 0” to start up the smpd again. As long as this process is
running you will be able to run applications where every process is allowed
to bring up GUIs.
:
http://www.mcs.anl.gov/research/projects/mpich2/documentation/files/mpich2-1.2.1-windevguide.pdf
It is possible. You use it the same way as any other MPI project.
In general, you can link against any C++ library from an MFC project. MFC is just a set of libraries, and doesn't restrict you from using other C++ libraries.
all, I have a rather frustrating issue. The application in question has an MFC GUI that uses the classes available in the MFC Featurepack. This GUI uses an DLL that is developed in C++\CLI. Our company uses Cruise Control. NET (1.4.4 SP1) on Windows Server 2008 SP2 for continuous integration. Cruise Control is setup to use the version of MSBuild that comes with the 3.5 version on the framework.
The issue in question is that if I use the build that Cruise Controls creates, I receive the following error: "Unhandled exception at 0x7642fbae (kernel32.dll) in FormView.exe: 0xE0434F4D: 0xe0434f4d." After some digging, the issue seems to be that the GUI doesn't like the C++\CLI assembly.
The "gotcha" is that if I log on to the server, and, using PowerShell, execute the same MSBuild command, the build works. Any one have ideas?
The issue was how I was building the installer. It was a separate solution from the project's main solution, and was thus a separate task from the primary build. Therefore, the output assemblies got signed twice, and loader complained because the one the application wanted was no longer valid.
you could try and attach the process to the visual studio debugger.