私は、プリンタ名を自動的に使用し、プリンタダイアログを開かずにデータを印刷する機能を持っています。 プリンターがもう存在しない、または名前が変更されている場合に、プリンター名をAリソースまたはAファイルとして保持したい場合は、次回のアプリケーション実行時に更新された名前を保持するようにしてくださいwpfアプリケーションの次の実行のためのデータ文字列を保存
質問は: これを実行するベストプラクティスは何ですか?
私は現在のconst文字列「PRINTER_NAME」 ようなコードをプリンタ名を保持している:任意の助け
private void print_DefaultNum_Print(object sender, EventArgs e)
{
bool isSent_ok = true;
// device-dependent string, need a FormFeed?
string s = "!U1 getvar " + "device.unique_id";
// Allow the user to select a printer.
PrintDialog pd = new PrintDialog();
pd.PrinterSettings = new PrinterSettings();
pd.PrinterSettings.PrinterName = PRINTER_NAME;
for (int i = 0; i < DEFAULT_NUM_COPIES && isSent_ok; i++)// send # of copies
{
isSent_ok = RawPrinterHelper.SendStringToPrinter(pd.PrinterSettings.PrinterName, deviceName);
if (isSent_ok == false)
{
if (DialogResult.OK == pd.ShowDialog(this))
{
// Send a printer-specific to the printer.
for (int j = 0; j < pd.PrinterSettings.Copies; j++)// send # of copies
RawPrinterHelper.SendStringToPrinter(pd.PrinterSettings.PrinterName, deviceName);
}
}
}
}
感謝を!
[アプリケーションの設定とユーザーの設定](https://msdn.microsoft.com/en-us/library/bb397750(v=vs.110).aspx)を参照してください。 – Clemens