Loading Printer Name - visual-studio-2005

I want to write code in C# for loading printer name in window. But I don't have any ideas to write it.
Can anybody help me to solve this problem?
Thanks. Ung Sopolin

Include a reference to the System.Drawing library and then:
var printers = PrinterSettings.InstalledPrinters.Cast<string>();
foreach (var printer in printers)
{
Console.WriteLine(printer);
}
I think you might be interested in this post.

Use PrinterSettings class from the System.Drawing.Printing namespace
PrinterSettings.InstalledPrinters
should return you a list of Printers.

PrinterSettings prSetting = new PrinterSettings();
Then prSetting.PrinterName will get you the name of the default printer name. You can use the same class for other Printer information.

Related

iOS 8 Photos framework: Get file name from PHAsset

Is there any way to get the file name from PHAsset object in iOS 8, same as like ALAsset's defaultRepresentation provides the file name?
// For ALAsset
let defaultRepresentation = self.asset.defaultRepresentation()
let filename = defaultRepresentation.filename()
NOTE: This can be done in iOS9 using PHAssetResource class. But I am looking for iOS8 and documented way of doing this(No undocumented APIs Please).
I did find the same question on SO but did not find the convincing answers, so I thought of asking it separately.
Any pointers would be greatly appreciated.
There have a private API called PHAsset.filename.
let filename = phAsset.value(forKey: "filename") as! String
You will get something like "IMG_193.PNG".
There is no documented way to do this on iOS 8.
The only thing you "might" use is the PHImageFileURLKey returned in the info Dictionary of the method requestImageDataForAsset: of PHImageManager. But even this is not fully documented.

PHPBB3and super globals?

I try to customize my PHPBB3 interface.
For that I need to include a header and a footer.
The header file I try to include has the use of...
$this->_agent = $_SERVER['HTTP_USER_AGENT'];
...wrapped in a function.
Here is the error message when I open the PHPBB3 index page:
Illegal use of $_SERVER. You must use the request class or
request_var() to access input data.
For info, the file I try to include works well in any other context than PHPBB3.
Can someone tell me what I have to do and where I have to do it in order to get rid of this error message and have my included file work properly?
Thank you.
You only have to use the request_var() function to access your datas.
$userAgent = request_var('HTTP_USER_AGENT','');
You can find more information about this function here :
https://wiki.phpbb.com/Function.request_var

Xtext get the absolute path of the generated files

I want to access the file generated by Xtext to compile it automatically. So I need its absolute path. It's enough to get the absolute path of the current project at run-time. Any idea how I can get it?
I am working inside the "MyDslGenerator" Class. I tried to get it from the "resource" in
override void doGenerate(Resource resource, IFileSystemAccess fsa)
but couldn't find it.
Help is highly appreciated.
I ended up using this code:
var uri = (fsa as IFileSystemAccessExtension2).getURI(fileName)
maybe you can use the Interface org.eclipse.xtext.generator.IFileSystemAccessExtension2. the passed IFileSystemAccess may implement this interface too.

vala / libxml2 : how to query xpath with namespace ? (xpathRegisterNs?)

how do you register namespace on context with vala so that you can query "//someNamespace:tag" (and not only "//tag")
My starting point is : https://live.gnome.org/Vala/XmlSample
Xml.Doc* doc = Parser.parse_file (path);
if(doc==null) print("failed to read the .xml file\n");
Context ctx = new Context(doc);
if(ctx==null) print("failed to create the xpath context\n");
Xml.XPath.Object* obj = ctx.eval_expression("/Example/Objects/Pet");
if(obj==null) print("failed to evaluate xpath\n");
I guessed[*] how to "create" some namespace
Xml.Ns* ns = new Xml.Ns(null,"","svg");
now how do I pass this namespace to the context ?
something like xpathRegisterNs that exists in .py (AFAIK)
Python XPath / libxml2 namespace query
If someone got some sample code to get the list of existing namespace in the doc it would be great too.
PS: [*] I say I guessed because I hoped I'd found a good Linux IDE with vala completion. Right now I'm stuck with Monodevelop 2.8.6.3 which has syntax highlighting for vala but no code completion (It keeps saying "fetching information for the class" but I don't get any result). So if someone knows of a good ide, I'll be glad to hear you...
You don't need to create the namespace as an object; that's only needed for registering it with a document. On the Context do:
ctx.register_ns("svg", "http://www.w3.org/2000/svg");
ctx.eval_expression("//svg:g");

Address Book is returning old values

I am having a problem with the AddressBook framework.
It all seems to be stemming from ABCopyRecordForUniqueId returning a record with old data.
Example:
I run up the program below in one terminal window - it shows the current data.
I make a change through the address book UI - my program continues to show old data.
I run up another instance of the same program in a new terminal window - it shows the updated data.
I have tried posting on the omnigroup site with no luck :( so any guidance is really appreciated
PS: If you would like to try the code, to get an address book ID you can export a contact as a vCard and open it with a text editor
int main (int argc, const char * argv[])
{
ABAddressBookRef addressBook = ABGetSharedAddressBook();
while(1)
{
ABRecordRef addressBookRecord = NULL;
addressBookRecord = ABCopyRecordForUniqueId(addressBook, CFSTR("4064D587-0378-4DCF-A6B9-D3702F01C94C:ABPerson"));
CFShow(addressBookRecord);
CFRelease(addressBookRecord);
sleep(1);
}
return 0;
}
I tried your example myself and am seeing the same problem. Out of curiosity, I tried asking for the shared address book inside the loop (in case there was some weirdness going on with the address book singleton) but this made no difference. I checked out the documentation (ABAddressBook C Reference) as well as the higher-level address book framework reference and guide. As far as I can tell, you're doing the right thing.
I'd file this as a bug against the framework.
thanks for the suggestion. I did file a report but it turns out this is expected
Annoying that it wasn't in the docs..
"Engineering has determined that this issue behaves as intended based on the following information:
The address book requires the run loop to be run in order to receive updates from other applications. Instead of sleep(1), use CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0, false)."
Thanks,
M

Resources