Personalized service printing - delphi

Good morning,
My problem is that I have a main program that calls a service (created by me, too) that it does is create some files subsequently sent to the print queue in Windows, the problem is when this program is executed by a windows 8 taking all permits and to run as administrator does not work, or prints or anything and gives the following error "no currently no default printer selected" (error completely random because if there default printer selected).
The service operation is simple, select the printer that there stored in the database and if this printer is the same as Windows sends the generated file in windows 7, xp, vista and other operating systems prior to Windows 8 functions perfectly.
Onsite windows 8 is 64 bits.
Thank you

I have already solved, I passed the source code to a normal program (without being a windows service) and it works perfectly.

Related

wrdDoc.SaveAs(SaveToFile); not working in windows 8

I have developed an app for computers a while back, that generates a word document and saves it automatically under a name provided by the software.
The application has worked perfectly in windows xp and windows 7. But now it needed to be moved to a windows 8.1 computer and since the generating works perfectly. But the save command wrdDoc.SaveAs(SaveToFile); does not work.
Basically what happens, is on that command's execution a save dialog appears and you can save the document yourself. After you click save. You get an error command failed with no further details.
Is there anything that has changed since windows 7 that prevents this code from executing properly?
The old computer used the following:
windows 7
office 2007/2010/2013(all were used at some point in time)
New computer:
windows 8.1
office 2010
UPDATE:
it is also worth noting, the dialog does not show any of the word documents in the folder if i browse there... Can this be a hint to the problem?
Resolved
I managed to find the problem. It's a brand new laptop, and Acer had a bunch of crap installed that sync's with office and explore. Once i uninstalled that the software returned to working normally...
Thank you guys anyway so much :)
It depends on your word version. Only 2007 has a "Saveas" method for the document object (https://msdn.microsoft.com/en-us/library/bb221597%28v=office.12%29.aspx). The later versions (2010 and 2013) only have a "Saveas2" Method (https://msdn.microsoft.com/en-us/library/ff836084.aspx)

Process Name Not Visible In Delphi XE Attach to process Dialog - cannot debug

Scenario:
Delphi ISAPI dll written using Delphi XE, 32 Bit.
ISAPI dll is running through IIS 7.5 on a Win 7 64 enterprise desktop
machine.
DLL runs fine.
Debug the ISAPI DLL in the Delphi XE IDE by using Run->Attach to
Process:
Launch the ISAPI DLL and attach to the wpw3.exe *32 process in the
debugger - can trace and debug code as it runs in the ISAPI context.
Problem:
My hard drive died last week and I got a new Win 7 installation - the
standard corporate wide Win 7 64 Enterprise image (not the same as my
previous Win 7 64 installation).
Now, when I go into Run->Attach to Process, I no longer see the
wpw3.exe *32 process by name, although it is visible in task manager
by name. Invoking the 'show system processes' option on the 'Attach to
Process' Dialog box does not help.
What I DO see now (which I never saw before in my old deployment) is
a long list of 'generic' System process with PID's but no
descriptions other than 'System'.
One of these processes is my wpw3.exe *32 process, and I have identified
its PID using MS's Process Explorer. But if I try to attach to
that process I get an error message - 'Cannot create process -
access denied' - so I can't debug. (Same error message 'Error
Opening process, Access denied' also shows in Process Explorer for
certain properties, although the descriptive name of the process '
wpw3.exe *32' is visible there, associated with the PID.)
How can I get the Run->Attach to process dialog box to display the
proper wpw3.exe *32 process name and attach to it, so I can debug?
Is this a Delphi problem? An IIS problem? An ISAPI problem? Is this one problem - ie lack of descriptive process name and inability to attach to process are caused by same problem; or is this two problems: one problem being lack of descriptive name, another the inability to attach to the process?
(Do not want to use - cannot really use - webApp debugger for this -
these are ISAPI dll's that are deployed to production exactly as they
are written and debugged in IIS - I need to see them running in IIS
context.)
Been debugging ISAPI dll's for several years this way, with different versions of Delphi and in various OS and server environments without any problems - never encountered this problem before. I am stumped.
My account has admin rights, but it hit me that I should try running DelphiXE as an admin – launch it with the ‘run as administrator’ option.
I got prompted ‘do you want to allow…’ – clicked yes and Delphi ran. Set up my process and hooked in and traced through my code - process names now visible and I can attach to my IIS process and debug in the Delphi Debugger.
I did not have to go through this step in my previous deployment, for whatever reason - but problem solved.
If you want to debug a 32 bit ISAPI dll on a 64 bit OS you can use the following process.
This assumes that you have followed other steps to allow 32 bit ISAPI dlls to work.
Stop IIS
net stop w3svc
Start the 32 bit worker process in debug mode
%SYSTEMROOT%\SysWOW64\inetsrv\w3wp -debug
Attach to the w3wp in the debugger. As you noted you need to be running Delphi with elevated privileges for this to work.

SmartCards in Windows 7

I'm using ACOS3X smart cards in my Delphi application for user authentication. Everything is fine in Windows XP, but in Windows 7, every time I put the card into the reader (which is ACR38-CCID), windows tries to install a driver for it, to no avail. This does not affect my application in any way, but it's really annoying. Should I write a driver for my card just to satisfy Windows 7? And, if yes, could someone please tell me if it's possible to create drivers with Delphi?
This is what Windows 7 (and IIRC also Vista) does. If you insert a smart card, it tries to locate a minidriver through Windows Update.
Not sure if it works, but you can maybe modify Windows registry to include the necessary entry for your card (but not point to a working implementation).
Look into Windows Minidriver Specification (available from MS) and the "discovery" section in that document.

Delphi 6 Exe on Vista: Problems with GetWindowText

I have an exe file compiled with Delphi 6 under Windows XP that uses a combination of EnumWindows and GetWindowText to find a window (not belonging to the exe itself) with a specific title.
The behaviour is as expected under Windows XP. On Vista computers however, it doesn't seem to work.
As the mentioned Delphi version doesn't run on Vista, I cannot change and test this directly.
However, I will try to create a modified exe on the XP computer that outputs some additional data and copy it to the Vista computer.
I would just like to ask whether anybody has any information whether there are specific problems known with exe files compiled with Delphi 6 running on Vista regarding EnumWindows/GetWindowText.
The exe uses EnumWindows and GetWindowText to find the handle of a certain window in order to then parse the title of that window in a timer event. The window title is the application name plus the name of the file opened in that application (if any file is opened). The Delphi exe analyses/uses this file name, does something with it and behaves in a certain way.
On Vista the expected behaviour does not appear, thus I presume that the window handle is not found cause GetWindowText does somehow not return the text. Another reason of course could be that EnumWindows does not work properly and the window handle of the window that the exe is looking for is never send to the EnumWindowsProc.
Assuming that there has been no change in window title from XP to Vista, there's not much that can go wrong here. I'd hazard a guess that the problem is due to UIPI. This is part of the security enhancements of Vista and it means that processes can only send messages to other processes that have equal or lower integrity level. Is this other process running elevated?
Other than that your best bet is to run this under the debugger. Delphi 6 most certainly does run on Vista. It was written before UAC and so doesn't get on well with having no rights to write to its install directory. So, install it to somewhere in your user profile or C:\Delphi6 – basically anywhere that standard users have write access.
Finally, don't fall into the trap of running Delphi elevated. This will confound the UIPI issue if indeed that is an issue here.
Good luck!

Delphi multithreaded application built in vista and won't run in XP

I am really stumped.
I am running delphi 2007 on vista. I have built many applications and run them in XP with no problem. This latest app had to make use of threads. I'm pretty sure my code is correct. It runs fine on Vista, but when I run it on XP (tried multiple PC's) my program seems to lag (both os's 32 bit, XP sp3 and Vista sp1, dotnet v2). Best example being if I unplug the serial port my coms will continue to run etc.
I was installing delphi on my xp machine, and ran my program while delphi was running. As in I ran it from the exe built in vista. It ran fine then. Close delphi, and the comport starts to lag again.
If I unplug and replug a flash drive, the coms catches up again.
I want to build the app on my xp based machine, but have like a million 3rd party components that makes it a real mission to setup.
Oh fyi, i built a simple application with just the main thread, and a comport thread. Same problem. All the comthread will do is fetch data off the comport. Not even display it, i used a serial port monitor in the background to check for the lag.
Any suggestions welcome.
OK quick edit: the XP pc is freshly built. I opened msn messenger, and the program runs fine. I'm obviously missing some setting...
If you're using Sleep in your threads (hence my comment/query to your question), you should use timeBeginPeriod to indicate your desired resolution. As you've already found out it doesn't matter where you call it; can be the main thread or even an entirely different application.
See this thread on embarcadero forums, and of course the documentation (remarks) on MSDN.
Are your OS installed on two diverse PC?
I guess one of your computer has a true dual-core processor (the one with XP), and the other (the one with Vista) has a one-core processor. Sometimes multi-threaded app reveals their problem when run on true multi-core processor.
The Delphi debugger sometimes change the CPU affinity, so it could work on the debugger, but not outside it.
Another possibility to check: try your software under XP with setting affinity to only one CPU.
I've seen that before. But it's likely something else, since you said you've tried your SW in multiple PCs.

Resources