I have created a Delphi service which is responsible for printing QuckReports to specific printers contained within the printer.Printers list. I pass my routine the printer name and it looks up in the printer.printers array to get the proper index. It then does this:
QuickRep1.PrinterSettings.PrinterIndex := iIndex;
In the help files it says this for printer.refresh: "Call Refresh when the installed fonts or printers on the current system may have changed". So I call the refresh before I look up the printer name against the printer.printers array.
At one of my installations this function is not working properly. If printers are added/deleted, or someone with printers under their profiles logs on, the list does not seem to get refreshed until the service is stopped and restarted.
Does this function not work for services?
The installation where this is occurring utilizes "virtual services". Could this have anything to do with it?
Thanks.
My experience and understanding is the printers array is updated only at application start. Anytime a new printer is installed, the application must be restarted to get the correct list.
I'm curious to hear any different experience with this myself.
EDIT: From my comment below; I wrote a small test program that confirms the TPrinters.Refresh() does update the printers list.
Related
Our users upgraded from Windows 7 to 10.
When they try to print using a custom print driver they get this error
The document Print Document, owned by User, failed to print on printer TEST-PRINT. Try to print the document again, or restart the print spooler.
Data type: NT EMF 1.008. Size of the spool file in bytes: 628788. Number of bytes printed: 12900. Total number of pages in the document: 6. Number of pages printed: 0.
Client computer: Devcomp. Win32 error code returned by the print processor: 2147500037. Unspecified error
Some of my observations: Internally we cannot reproduce this error internally. I have a windows 10 surface and also tried on a windows 8 machine. Our support tried it here too.
The customer can reproduce the issue without. The issue happens for some documents on some workstations. The PDF is generated from a 3rd party application for tellers. The customer saves the pdf from this signature desktop application to a PDF and uses our print driver to print to the our application.
Our print driver converts the file to PCL and sends it to the subscriber for further processing.
I can provide more info if needed regarding print driver. First of is it a problem with the print driver?
All the users who upgraded from windows 7 to a windows 10 laptop can see the issue happening. There are some windows 10 workstations that print just fine. Could it be something with the group policy or some registry settings. If I were to compare the registry or policies on the workstation that prints and the one that fails what would be the settings I need to look for? The customer's IT says that there is no difference between the two workstations except that it’s the production workstation that fails. Typical response nothing different but it doesn't work.
We also tried to disable “render print jobs on the client workstation” but this didn’t seem to make difference. I am happy to try any suggestions you’ll have.
I am looking for ideas of what kind of research and where should I start troubleshooting.
I won't be troubled if anyone chooses to vote the question down that I didn't do any research since I really don't know where to start. I am a .NET developer not a windows driver expert or systems admin.
Process Monitor Good File. The file gets created.
Create file success, create file name not found and finally create file succcess
Bad File: Create file success, create file name not found. The last create file is not called by the print.exe driver.
This solved my problem. Thanks Papercut!.
https://www.papercut.com/kb/Main/FixingPrintSpoolerCrashes
https://www.papercut.com/kb/Main/EnableAdvancedPrintingFeatures
I need information on how to allow an end user to compose an email, in Delphi code. Our Delphi version is Delphi Seattle (I think that is 10.1?) We use office365 as our email program. I need to pre-fill the recipient and some html in the body of the email. The end-user needs to complete the body of the email then click the send button.
We used to use the reliable "mailto" commandline that then displayed an email form. But it only works with plain text, no html. I now need to have html in the body of the email. I switched to using the ancient semi-reliable TOutlookApplication component and using it in code to do this thru OLE. I do see a dialog pop up, and the html appears to render correctly, but the send button seems to do nothing. Looking at the code used by TOutlookApplication, it appears that it's not been updated since the glory days of XP.
I am using Delphi Seattle. I don't think I can use Indy components with stmp because the email dialog has to be present to allow for the composing of the email, and I didn't see a way for Indy to display the form. Can anybody please tell me what I gotta do to make this work? If anybody wants to see my current code using TOutlookApplication, I can post it, but it's like 1,000 other Delphi examples of the component. Surely, others have overcome this, right?
I have additional information on this. I was running my application on a virtual machine, but my outlook was running in the desktop. Once I run the application on the desktop, it ran fine. I even received the test emails I hadn't from the vm. I believed the vm was aware of the desktop applications. My bad!
The problems I experienced were due to running on a virtual machine. If there are other dolts trying to run an app that uses OLE to access Outlook from a VM, make sure you have a Outlook ON THE VM. Or run your app from the someplace that has Outlook installed, like a desktop.
Today I started to write my first web application and I can't pass one step.
Everything works almost fine... I can connect to the server and open website. Problem is when I open browser and type the same address on the second pc, then I get te same data as on the first one.
Detailed...
Application has two forms, first is for login, and second one is for receiving data.
When I login on the first pc and second form shows up, and then I open browser and put the address of the server on the second pc, I see the second form after login from first pc.
What I should do in this case? I tried to find the solution in the net, but I couldn't :(
If you are using any Delphi IDE after XE3 (including) and using the IntraWeb edition that comes with Delphi you must upgrade in order to have it working correctly. It is free, and more information can be obtained here:
http://atozed.com/IntraWeb/Download/FreeKeyRequest.EN.aspx|
After upgrading (if this is your case) I suggest you to take a look at one of the IntraWeb demos, here:
https://iwdemos.codeplex.com/SourceControl/latest
There is a demo named Features that shows you exactly how to create a multi form application. To be honest, I work with IntraWeb for a long time and I've never seen that. Unless you are using some global var to hold your "current" active form. Have in mind that IntraWeb is a fully multithreaded application and global vars should not be used, unless you have some mechanism protecting concurrent access (but you should get rid of them and use ServerController properties instead).
Thnks for your quick reply.
I work with Delphi from some time, but I never used Intraweb, I worked with ComPort and IP works for I/O devices. I have XE7 and I upgraded Intraweb to 14.0.52.
I can't find a good file exchange server to put my application for sharing with you. If I find somethin I will post it below.
You can check the code and other settings of my simply project. I put the web application inside the link below, it is without the .exe file.
https://www.dropbox.com/s/75zurcew0zr363x/Project1.rar?dl=0
Thanks for your help.
Can I get a little code example to use DDE as a server? I know how to use the client part, but can't figure setting up my app to act as a server and receive data.
Have a look in your Delphi installation for a folder called DDEDemo. It's a DDE project that Delphi use to ship with (I'm not 100% sure it's still included, but have a look). The demo includes a DDE client and server.
Edit - Try this link for some example code.
It is so easy to use the DDE server that you don't even need sample code. You can do it just at designtime inside the Delphi form designer:
To create a server that sends out data:
Drop a TDDEServerConv and
TDDEServerItem on your form or data
module.
Connect the server item to
the server conversation (set
DDEServerItem1.ServerConv=DdeServerConv1
using object inspector, there is a
drop down list, but double clicking
it is enough).
Set the DDEServerItem.Text value to some valid text value (ie 'A')
To receive data, you might want to have macros that are executed by the DDE client that pass data to the server. For this you use the DdeServerConv.OnExecuteMacro event. Try dumping the parameter Msg:TStrings to a memo like this:
Memo1.Lines.Assign(Msg);
Now save and run your project.
To test it in excel type in:
=Project1|DdeServerConv1!DdeServerItem1
The excel dde client syntax parts are Application name followed by vertical bar, conversation name, followed by exclamation mark, then item name.
And you will see the value (A, or whatever you put into the Text property in the item) appear in Excel.
That's a working single item DDE server without any code written by you.
I generally find that I create the conversations and the items at runtime, instead of at designtime, in a real world scenario that is more useful for me.
For older (non unicode) Delphi versions there is also a full featured commercial product called Django that helps a lot with DDE work.
I think also you might be looking for information on how to write a "DDE Poke" command handler on the delphi side. I don't have a demo for that. I tried it, and the obvious things didn' quite work right for me (the item on your server has an OnPoke event, I wrote a simple client, called PokeData, and it didn't work).
I have created a Delphi Service which prints TQuickReports. Everything works fine if compiled and run as a Windows Application. But when converted to operate as a service trying to create a form containing a TQuickRep component throws the exception.
This service runs fine on many other boxes but not this one in particular. Here are some details:
Using QuickReport version 4.07
Box is a Windows Server 2008 operating system.
Using Delphi 2007
Printer.Printers.Count is returning a positive value. In fact I can list out all of the printers.
I have tried running the service both using Local System Account and Logged on as an Admin.
Is there a default printer set up in session 0? Remember that under Vista / Server 2008 / Windows 7, services run in a separate session. Whether or not the logged-in user has a default printer set is not relevant - it's a per-session setting and doesn't affect session 0.
Can you rewrite the code to gracefully handle that exception and pick a printer to use?
You can solve this problem by creating a new dword UserSelectedDefault with the value: 1 in
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices\Session_ID
Make sure you have a local printer selected.
You might give the user a way to select the printer for the service. The Windows service probably does not have a default printer set.
Set TQuickRep.PrinterSettings.PrinterIndex to set the printer number. Then, TQuickRep.Print to print the report.
A colleague ended up finding the solution. I should have added these are "network" printers and not Local printers (at the time I didn't think this was related to the problem). So the service needed to be installed with "NetworkService" as the user account under the logon tab. From the Windows Help:
To specify that the service uses the Network Service account, click This account, and
then type NT AUTHORITY\NetworkService
We had a simular problem here. Using TS servers, Citrix and Powerfuse 9.
Powerfuse had all printers capitalized, however they were shared in a mixed case.
This combination caused Delphi/QReport to crash
When all printers are from printserver to powerfuse in the same case (not important upper or lower or even mixed), the problem was gone
Actually it is a Delphi(5) problem. The comparison of the available printers and the default printer is case sensitive (Printers.pas):
if TPrinterDevice(Objects[I]).Device = Device then
begin
with TPrinterDevice(Objects[I]) do
SetPrinter(PChar(Device), PChar(Driver), PChar(Port), 0);
Exit;
end;
Changing the comparison to:
if lowercase(TPrinterDevice(Objects[I]).Device) = lowercase(Device)
solves the problem.
If using terminal services 2008, same user for multiple sessions, you should look into the:
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices\Session_ID
instead of
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\
I solved a similar problem: If a Delphi application (or service) uses QuickReport, it runs before the system loads the default printer (or printers).
When QuickReport executes TQRPrinter.Init, the printer.printers.count is zero,
shortly after the system loads, the printer.printers.count is the number of printers,
but tqrprinter.int has already executed, so TQRPrinter.FPrinterOK is false,
you then see this error when you try open a QuickReport.
The solution for me was wait until the printers were loaded before launching the application (in citrix and terminal server). I solved this in two ways, either by overwriting tqrprinter or delay the dpr.