I'm not a developper. We want ( me and our team)to write a tool in C++ that can print a PDF ( Send a PDF to printer). We tried to use external tool, like a command line pdfprint.exe, using CreateProcessW and cmd /c, but we have a problem. With Windows XP we don't have problem with our tool, with Windows Vista we have problem and we cannot using the tool like pdfprint.exe.
There are differences between Windows XP and Vista to launch external tools within another program with CreateProcessW and "cmd /c"?
Thanks
Oronzo
There are many approaches to run external application from your C++ programm. I will count them below.
Win32API CreateProcess function. Cédric Julien gave example of use.
exec* C/C++ function family. They are defined in POSIX standard. So they are the same on Linux. But because they are deprecated in new version of MSVC, try to use analogical _exec* function.
WiNT Native API Call - NtCreateProcess. It is called in CreateProcess also :-) And this function represents deeper level of API. With use of Native API calls you can write small and simple applications, because you will make lesser number of dependencies of your program with external libraries. But there are issues: native API is binded to OS version, so there aren't any garanties that Native API will be the same in next OS versions.
You may try each. Please, note that it is good idea to point in each call to these functions full path to executable file. Also you must have read/execute rights (permissions) on pdfprint.exe. If you don't have such only way to execute external tool is to run your C++ program with administrative rights. You can run it such way if you right click on exe-file of your program and select "Run As Administrator" menu element.
As described here, you should use something like this :
LPTSTR szCmdline = _tcsdup(TEXT("C:\\Program Files\\....\\pdfprint.exe -args-you-need"));
CreateProcess(NULL, szCmdline, /* ... */);
Related
I would like to be able to access TButton TCheckBox TEdit etc.. of a running Delphi application from a Lua script.
It is a retail Delphi application so I have no access to the source code. I would normally use AutoHotKey but would like more control.
Is this possible as I seem to be able to change things with the Enabler below. Could it be done by integrating Lua into a Delphi app and use it to send to the retail Delphi app ?
Or is there another way ?
An open source solution would be best so to make it available to others.
I use Reaper DAW and it has API for Lua scripting I would like to be able to do similar with the Delphi app without the API available.
In order to run any script in a specific application then that specific application needs to have suitable scripting capabilities built into it in order to be able to interpret that script accordingly.
Now I'm guessing that "retail" application you are using doesn't have LUA scripting built into it otherwise you probably wouldn't be here.
So I'm afraid that the answer is no. You can't interact with a third part application from LUA script unless that application is designed to work with LUA scripts.
I am new to Lua. I have an ARM Cortex based product with an OS providing TCP stack, SD card for file storage, and lots of custom hardware. I have embedded Lua (from the standard source distribution) into the product and added an API to give Lua access to my hardware. Also have Telnet and FTP services running. Works great.
Now I would like to add the ability to debug scripts with ZeroBrane. Looks like I need to add MobDebug, and connect it to my OS thru LuaSockets. Assuming this is a valid approach, can anybody point to a tutorial or documentation that would help?
Thanks
Assuming you have access to luasocket on that platform, you can follow the instructions on remote debugging with MobDebug and ZeroBrane Studio. It should be a matter of adding require('mobdebug').start('IP-of-computer-running-ZeroBraneStudio') and making project files available in ZeroBrane Studio.
ZeroBrane Studio also does mapping between different file systems to allow debugging of scripts running on one platform from the IDE running on a (possibly) different platform. You only need to make sure you have the same project structure. For example, you may have /usr/me/myprojects/projectA/fileB.lua and start debugging of projectA/fileB.lua in /usr/me/myprojects/; then on the IDE side you may have D:\Users\Me\myprojects\projectA\fileB.lua opened in the IDE and it will attempt to map /usr/me/myprojects/ to D:\Users\Me\myprojects\. If you run into issues, you can use IRC or the maillist to get further help.
I have made a simple installer application in Delphi, nothing fancy. Basically I include files into the Exe, and then extract them to a user specified path.
I stumbled across a problem however, and I have noticed this works with ANY Windows Executable, it does not matter if it is an installer or not.
If an Exe is named, or contains the following words in the filename, "Setup", "Build", "Install" and maybe others, then.. whenever the Application is run and closed, Windows pops up a Product Compatibility Assistant dialog, saying the Application may not have installed correctly.
This is a problem, as even though the Files from my installer have actually extracted, and in my eyes the installer has done its job, Windows is complaining about it.
The only idea I have regarding this, is that Windows must check the filename of the Applications when executed, and in this case has identified it as an Installer. Windows must of then set a flag or something on the System, my Installer must then update this flag to say that the installation was a success?
Windows does not complain about this when debugging from the IDE, so it cannot be code related, it must be the OS - this only happens when launching the Application from Windows, not Delphi.
You can try this easily, either create an Application or rename one as Setup.exe, Run it and then close it - wait a few seconds and the Product Compatibility Assistant Dialog will show.
I don't know where to start investigating how to stop this dialog, or where a setting may be to tell Windows the Installer was completed correctly.
Appreciate your thoughts and solutions thanks.
If I recall correctly, this happens when your install app does not include an application manifest. When UAC was introduced, MS introduced a heuristic detection for installers and shows the UAC elevation dialog. The heuristic checks for names like setup.exe, install.exe. The simple solution is to include an application manifest. If it is an installer you probably want to use the requireAdministrator setting.
The feature is known as Installer Detection and is discussed here.
For what it is worth, I would always build an installer with a dedicated install tool like InnoSetup for example.
As David pointed out, MS uses some fuzzy logic to try to guess if the program is an installer. I wouldn't rely on this, as this is only for supporting legacy installer applications.
All new applications should have a manifest file, specifying whether it requires elevated privileges.
If an application has a manifest file that includes the requestedExecutionLevel directive, then Windows does not attempt Installer Detection.
Any program that is detected as an installer program but does not add a registry entry to the Add Remove Programs section of the registry (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall) will get the message "This program might not have installed correctly".
I want to monitor the copy file function using Delphi.
I can do it in windows explorer with shell notifier.
My problem is when copying file with the command prompt.
How can I monitor the progress of a copy file operation that has been initiated at the command prompt, using Delphi?
I personally used these two:
When using .NET, use the System.IO.FileSystemWatcher class.
When using Win32, use a combination of FindFirstChangeNotification, FindNextChangeNotification and FindCloseChangeNotification.
Ah - just found out the Win32 portion of your question is also answered here, and that answer has a code example.
There is also another Win32 way of doing this: using ReadDirectoryChangesW, but I don't have personally used it.
Good luck!
--jeroen
I'm using flex (lexical analyzer, not Adobe Flex) on a project. However, I want to be able to compile on Windows platforms as well, but the Windows version's newest version is only 2.5.4a, so it won't compile my file for version 2.5.35. And no, I can't downgrade to the highest supported Windows version.
Anyone know about plans to upgrade the windows version, or have a suggestion to compile on windows anyway?
You can ask on the mailing list, or get involved in the Flex project yourself. I think the code-base for Flex has remained static for a while, but I don't know who maintains the Windows port. In the interim...
I would recommend including the produced source in your project.
Generate the lexer on a Linux system to produce your lex.c/lex.h files (or whatever)
Include those files in your Win32 C source before you build
If you don't have direct access to a Linux system, a virtual machine might be a good idea. The Flex source should be complaint to some C standard that builds on Windows, but most of the POSIX differences can be altered to use Win32 API fairly easily.
Maybe distribute as:
/src/source_files.c
/src/lex.l
/src/win32_lex/lex.c
This way systems with a modern flex can generate the source from the lex file, and Windows systems compiling the source can use the complementary pre-processed C files.
Short of using some user-space POSIX (Cygwin or whatever).
A little bit of tweaking required, but isn't that portability for you!
Windows builds of flex 2.5.35 do exist, but unfortunately they are not self contained. You can download the MINGW build here, and the Cygwin build here; see also another stackoverflow question. Each build requires that its respective (MINGW or Cygwin) kernel be installed.