示例#1
0
        public PMStatusCode TryGetPaperList(out PMPaper [] paperList)
        {
            IntPtr m;
            var    code = PMPrinterGetPaperList(handle, out m);

            if (code != PMStatusCode.Ok)
            {
                paperList = null;
                return(code);
            }
            int c = (int)CFArray.GetCount(m);

            paperList = new PMPaper [c];
            for (int i = 0; i < c; i++)
            {
                paperList [i] = new PMPaper(CFArray.CFArrayGetValueAtIndex(m, i), owns: false);
            }

            return(PMStatusCode.Ok);
        }
示例#2
0
        public static PMStatusCode CreatePrinterList(out PMPrinter [] printerList)
        {
            IntPtr arr;
            var    code = PMServerCreatePrinterList(IntPtr.Zero /* ServerLocal */, out arr);

            if (code != PMStatusCode.Ok)
            {
                printerList = null;
                return(code);
            }
            int c = (int)CFArray.GetCount(arr);

            printerList = new PMPrinter [c];
            for (int i = 0; i < c; i++)
            {
                printerList [i] = new PMPrinter(CFArray.CFArrayGetValueAtIndex(arr, i), owns: false);
            }

            CFObject.CFRelease(arr);
            return(PMStatusCode.Ok);
        }