开发者

Print files from a folder in PowerBuilder 12

I am not familiar with PowerBuilder at all. We have a problem in our application that is built in powerBuilder 12.

The application calls a WCF ser开发者_StackOverflow社区vice written in .Net. The service returns path of a document that it downloaded.

Is there a way I can print the document without opening it in PowerBuilder? Once the service returns the path, I need to print the document in the default printer.

Any help greatly appreciated.

thanks


You can hook up one of the standard Windows API calls ShellExecute

 Function long ShellExecute( long hwnd,  string lpOperation, string lpFile, string                  
          lpParameters,  string lpDirectory,  integer nShowCmd ) Library "shell32.dll"   
          alias for "ShellExecuteW"

Once you have done this, you can send your path/file to this function and tell it to print, like so:

 integer        li_return_code
 string     ls_null
 long       ll_null

 SetNull(ls_null)
 SetNull(ll_null)

 li_return_code = ShellExecute(ll_null, "print", "C:\File.pdf", ls_null, ls_null, 0)

The return code can be a number of values, but anything greater than 32 means success. Lower values dictate an error, which you can get descriptions for off of MSDN.

One of the 'pre-reqs', if you will, is that you will have to have the proper application installed and registered for the file extension of the file you're passing in for this to work.

And, just FYI, we seem to always have problems with ".txt" files. They never work through this call.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜