errorcode 183 when DrvDocumentPropertySheets being called. In my UI wrapper

Hi all :slight_smile:

Also a question related with my printer UI wrapper.
following the tip from here, i tried lot of things to understand what’s
happening when DrvDcumentPropertySheets being called in special situation.

  1. Using Microsoft Word.
  2. click printer icon(in every app supporting printer).
  3. choosing File -> Print menu(also in every app supporting printer).

is these situations, module failed to load the library “unidrvui.dll” and
setted the errorcode 183, which stands for
“Cannot create a file when that file already exists.”
(Checked with GetLastError)

So i made a few trial to correct this. first, i changed the HINSTANCE
variable “hInstUniUI” which holds the loaded library as a global variable,
and initialized as NULL.
Then i loaded only when variable had NULL value. like the following code.

FARPROC UIDllFunc; // function pointer
char buf[50];

if(hInstUniUI == NULL){
//hInstUniUI : the global variable holding library.
if((hInstUniUI) = LoadLibrary(_T(“UNIDRVUI.DLL”))){
MyFilePrintLine(" Successfully Loaded UNIDRVUI.DLL");
}
else{
MyFilePrintLine(" Loading UNIDRVUI.DLL failed ");
sprintf(buf, “Last error %ld\n”, GetLastError());
MyFilePrintLine(buf);
return (NULL);
}
}

UIDllFunc = (FARPROC)GetProcAddress(hInstUniUI, function_name);
// function_name : a (char*) variable pointing the name of the function,
// for example, “DrvDocumentPropertySheets”

it worked similar as before, but library was loaded only in the first time
when installing. properties of the printer was successfully displayed,
But in the situation(using Microsoft word, trying to print etc…),
DrvDocumentPropertySheets tried to load the library, and it failed, and
my module returned the NULL pointer. (could see this in the log file)

So i did another try. I made changes in DrvDocumentPropertySheets module
as follows.

DrvDocumentPropertySheets(
PPROPSHEETUI_INFO pPSUIInfo,
LPARAM lParam
)
{
FARPROC UIDllFunc = NULL;
LONG Value;

UIDllFunc = WrapUnidrvUI(“DrvDocumentPropertySheets”);

if(UIDllFunc == NULL){ // When fails to load library
//after initializing the global variable. try to load library again.
FreeLibrary(hInstUniUI);
hInstUniUI = NULL;
hInstUniUI = LoadLibrary(_T(“unidrvui.dll”));
UIDllFunc = GetProcAddress(hInstUniUI, “DrvDocumentPropertySheets”);
}

Value = (*UIDllFunc)(pPSUIInfo, lParam);
return (Value);
}

But i didn’t work also. :frowning:
I know that it goes trough the “if” block in the middle but it also
failed to load the library.

So at last i just modified the DrvDocumentPropertySheets module as…

DrvDocumentPropertySheets(
PPROPSHEETUI_INFO pPSUIInfo,
LPARAM lParam
)
{
FARPROC UIDllFunc = NULL;
LONG Value;

UIDllFunc = WrapUnidrvUI(“DrvDocumentPropertySheets”);

if(UIDllFunc == NULL){ // When fails to load library
return (1);
}

Value = (*UIDllFunc)(pPSUIInfo, lParam);
return (Value);
}

after this, The MS Word didn’t died and, i could choose the File -> Print
menu. But after choosing this menu or clicking the print icon, I could see
other function calls(such as DrvQueryColorProfile, DrvDeviceCapabilities)
failing(=cannot load UI library) with the same error code 183.

Why is this problem happening?
what shall i do to make DrvDocumentPropertySheets function success in
every situation?

I wish i could listen for advice.
Please help me with it. I’ll be looking forward to it.

-with respect
Souneil