Hello,
Is there in Aurora an equivalent to the getdefaultprinter function of Ebasic?
???
Haim
No. But I can add it for the next update ;)
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;
}
Thanks for your reply. Adding the function to the next release will be greatly appreciated!
Haim