Показать сообщение отдельно
Старый 25.02.2009, 09:41   #13  
petergunn is offline
petergunn
Участник
 
118 / 274 (10) ++++++
Регистрация: 30.08.2005
Адрес: Tyumen
Цитата:
Сообщение от Eldar9x Посмотреть сообщение
Дополнительно к функции WinAPI::EnumPrinters создайте еще одну:
X++:
static client server str GetPrinterPort(str _printerName)
{
    DLL         _winApiDLL = new DLL("kernel32.dll");
    DLLFunction _getProfileString = new DLLFunction(_winApiDLL, 'GetProfileStringA');
    ...
}
imho, использование GetProfileString не лучшее решение, т.к. эта функция в API присутсвует только для обратной совместимости с 16-bit приложениями.

Цитата:
GetProfileString Function

Retrieves the string associated with a key in the specified section of the Win.ini file.

Note This function is provided only for compatibility with 16-bit Windows-based applications, therefore this function should not be called from server code. Applications should store initialization information in the registry.
Цитата:
Windows Server 2003 and Windows XP/2000: Calls to profile functions may be mapped to the registry instead of to the initialization files. This mapping occurs when the initialization file and section are specified in the registry under the following keys:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\
CurrentVersion\IniFileMapping
Более подробно тут (msdn).
В случае маппинга секции HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\IniFileMapping чтение ключа "Devices" приведет к обращению к ветке реестра USR:Software\Microsoft\Windows NT\CurrentVersion\Devices

Последний раз редактировалось petergunn; 25.02.2009 в 10:06.