"No Default Printer" message on Windows 7 64-bit

Re: "No Default Printer" message on Windows 7 64-bit

Postby James Bott » Thu Oct 07, 2010 2:28 pm

Hua,

Did you see my previous post? Can you test and answer my questions?

What makes me confuse and giving me a headache is FWH\Samples\testprn2.prg works perfectly even if I run it from the file server.


This indicates there is a problem in your code--we just need to find it. Or, you might be in the Twilight Zone...

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: "No Default Printer" message on Windows 7 64-bit

Postby Randal » Thu Oct 07, 2010 2:54 pm

Hua:

I understand you cannot set Compatibility mode from the workstation. I just wanted to see if changing the icon properties would make it work on the local computer. I understand this is not the ultimate solution.

Do you use any 3rd party libraries or dll's?

Try putting this as the first line in your app. You'll need to undo the icon property changes so you can recreate the original problem.

PrintBegin( nil, .f., .f.,, .f., .f.)

Open your program try the print function again.

If you are using any 3rd party lib or dll it may be that calling a function from one of these is causing your program to be opened with limited permissions. Putting the PrintBegin at the start should cause your program to open with extended permissions. You can then move the PrintBegin call further down in your program's startup until you find the offending function call, i.e. the point beyond which the PrintBegin doesn't cause your program to open with extended permissions.

The fact that the sample program works fine is an indication that something different is happening in your program.

Thanks,
Randal



hua wrote:Hi Randal,

I think I can safely eliminate permission as the issue, (then again it actually kinda behave that way). Here's a summary of what I've done:
i. Run as administrator
ii. Linked in manifest to auto-elevate the exe's priviledge to Admin
iii. Enabled the hidden Administrator account on Win7 and use that one to login and execute my program.
iv. Turn off UAC altogether.

The programs are actually on a file server (FreeNAS) and being run from the Win7 client, so Set Compatibility can't be used as it only works with local files.

What makes me confuse and giving me a headache is FWH\Samples\testprn2.prg works perfectly even if I run it from the file server.

From searching the forum it seems I'm the only one facing this issue. Maybe I'm stuck in a twilight zone or something that's why this strange thing happens to me and only me :roll:

Hmm... I can't recall trying to run it locally. Maybe I did but then forgotten about it. I'll try that next
Randal
 
Posts: 260
Joined: Mon Oct 24, 2005 8:04 pm

Re: "No Default Printer" message on Windows 7 64-bit

Postby hua » Fri Oct 08, 2010 8:58 am

Thanks for the reply guys :)

@Richard: I'm not using any ini at the moment.

@James: Oops, sorry I missed your Oct 6th's post. The hDC is 0 only in my module James. It definitely isn't 0 when running samples\testprn2.prg. I even compile and linked in libs as per how I do with my problematic module yet testprn2.prg still runs with no problem. So it seems likely that something within my code is causing this problem but I'm not certain how to go from here. I mean at the top of the module, I inserted these 3 lines, just to see what I would get:
Code: Select all  Expand view  RUN
? GetDefaultPrinter()
Printersetup()
? ud_prngetname()
...
function ud_PrnGetName()
 local cret, oprn
 PRINTER oPrn
 cRet := oPrn:getmodel()
 endprint
return cret
 


The results,
GetDefaultPrinter() - a function in xHarbour pointed to me by Stefan, works with no error and returns the default printer name

Printersetup() - nothing happens at all

UD_PrnGetName() - a function I written myself a while back when I didn't know of GetDefaultPrinter() existence. This one would cause the message "There are no printers installed! Please exit this application and install a printer" to appear. Clicking Ok after that message would yield "The instruction at 0x0041995d referenced memory at 0x00000002. The memory could not be read. Click on Ok to terminate the program."

Now to further confuse the matter, I did some of the printout using Fastreport and so far it can always do a preview with no problem whatsoever.

Hey, is it possible this happens because the PC is moody? Wonder whether my boss would accept that excuse ;)

@Randal: I have 3rd party libraries and dll's but not that many. One is SoftwareKey for copy protection while the other is Fastreport. Thanks for your idea Randal, it's something that has never crossed my mind. I'll give it a shot.

What bugs me about this whole thing is UAC has been completely turned off and user account is already of administrator type and yet it still display symptoms of inadequate permission.
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: "No Default Printer" message on Windows 7 64-bit

Postby hua » Fri Oct 08, 2010 9:34 am

Got it! Thank you Stefan, Richard, James, Gilbert and especially you Randal! Your idea pointed me to the right direction. Softwarekey's dll was the culprit. Here's what happened, somehow when Softwarekey's dll (keylib32.dll) is called to validate the license, no matter what I do, my exe won't get the permission to access the printer drivers. Even if I set the compatibility mode it doesn't help at all. To be fair this dll is quite old but then again as long as it's a 32-bit version shouldn't it have worked?

Fastreport's dll doesn't seem to have this problem at all.

Again, thank you so much. Appreciate you guys all :D
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 35 guests