April 23, 2024, 08:41:21 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


GetDefaultPrinter in Aurora?

Started by Haim, January 06, 2007, 07:03:00 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Haim

Hello,
Is there in Aurora an equivalent to the getdefaultprinter function of Ebasic?

???
Haim

Ionic Wind Support Team

No.  But I can add it for the next update ;)
Ionic Wind Support Team

Ionic Wind Support Team

Here is a quickie example you can use until the next update ;)


sub main()
{
openconsole();
print(MyGetDefaultPrinter());
while GetKey()=="";

}

#define PD_RETURNDEFAULT 0x400

struct PRINTDLG,1
{
    unsigned int lStructSize;
    unsigned int hwndOwner;
    unsigned int hDevMode;
    unsigned int hDevNames;
    unsigned int hDC;
    unsigned int Flags;
    WORD nFromPage;
    WORD nToPage;
    WORD nMinPage;
    WORD nMaxPage;
    WORD nCopies;
    unsigned int hInstance;
    unsigned int lCustData;
    POINTER lpfnPrintHook;
    POINTER lpfnSetupHook;
    POINTER lpPrintTemplateName;
    POINTER lpSetupTemplateName;
    unsigned int hPrintTemplate;
    unsigned int hSetupTemplate;
}

struct DEVNAMES,1
{
    WORD wDriverOffset;
    WORD wDeviceOffset;
    WORD wOutputOffset;
    WORD wDefault;
    // driver, device, and port name strings follow wDefault
}


DECLARE IMPORT,PrintDlg ALIAS PrintDlgA(pd as PRINTDLG),INT;
DECLARE IMPORT,ZeroMemory ALIAS RtlZeroMemory(pvoid as POINTER,length as INT),INT;
DECLARE IMPORT,GlobalLock(handle as unsigned int),unsigned int;
DECLARE IMPORT,GlobalFree(handle as unsigned int),unsigned int;
DECLARE EXTERN _fpreset();

GLOBAL SUB MyGetDefaultPrinter(),STRING
{
DSTRING strPrinter[64] = "";
PRINTDLG pd;
POINTER pString,pTemp;
ZeroMemory(pd,LEN(PRINTDLG));
pd.lStructSize = LEN(PRINTDLG);
pd.Flags = PD_RETURNDEFAULT;
PrintDlg(pd);
_fpreset();
IF pd.hDevNames
{
pString = GlobalLock(pd.hDevNames);
pTemp = pString;
pString += *(DEVNAMES)pString.wOutputOffset;
strPrinter = *(STRING)pString;
if(strPrinter[0] != "\\")
{
pTemp += *(DEVNAMES)pTemp.wDeviceOffset;
strPrinter = *(STRING)pTemp;
}
GlobalFree(pd.hDevNames);
}
IF pd.hDevMode
GlobalFree(pd.hDevMode);

RETURN strPrinter;
}
Ionic Wind Support Team

Haim

Thanks for your reply. Adding the function to the next release will be greatly appreciated!

Haim