|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#pragma warning(disable : 4996)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <windows.h></windows.h>
|
|
Shinya Kitaoka |
d4642c |
#include <stdlib.h></stdlib.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "ttwain_state.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ttwainP.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ttwain_statePD.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ttwain_util.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef __cplusplus
|
|
Toshihiro Shimizu |
890ddd |
extern "C" {
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static void *hDSMLib; /* handle of DSM */
|
|
Toshihiro Shimizu |
890ddd |
extern void TTWAIN_SetState(TWAINSTATE status);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TTWAIN_LoadSourceManagerPD(void) {
|
|
Shinya Kitaoka |
120a6e |
char winDir[_MAX_PATH];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (TTWAIN_GetState() >= TWAIN_SM_LOADED)
|
|
Shinya Kitaoka |
120a6e |
return TRUE; /* DSM already loaded */
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
GetWindowsDirectory(winDir, _MAX_PATH);
|
|
Shinya Kitaoka |
120a6e |
if (!winDir[0]) return FALSE;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
fd19c4 |
strcat(winDir, "\\system32\\");
|
|
Shinya Kitaoka |
fd19c4 |
// strcat(winDir, "\\");
|
|
Shinya Kitaoka |
120a6e |
strcat(winDir, DSM_FILENAME);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
hDSMLib = LoadLibrary(winDir);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Toshihiro Shimizu |
890ddd |
if (tnz_access(winDir, 0x00) != -1)
|
|
Shinya Kitaoka |
120a6e |
hDSMLib = LoadLibrary(winDir);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
hDSMLib = 0;
|
|
Shinya Kitaoka |
120a6e |
return FALSE;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (hDSMLib) {
|
|
Shinya Kitaoka |
120a6e |
TTwainData.DSM_Entry =
|
|
Shinya Kitaoka |
120a6e |
(DSMENTRYPROC)GetProcAddress(hDSMLib, DSM_ENTRYPOINT);
|
|
Shinya Kitaoka |
120a6e |
if (TTwainData.DSM_Entry) {
|
|
Shinya Kitaoka |
120a6e |
TTWAIN_SetAvailable(AVAIABLE_YES);
|
|
Shinya Kitaoka |
120a6e |
TTWAIN_SetState(TWAIN_SM_LOADED);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
FreeLibrary(hDSMLib);
|
|
Shinya Kitaoka |
120a6e |
hDSMLib = NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
fd19c4 |
} else {
|
|
Shinya Kitaoka |
fd19c4 |
DWORD err = GetLastError();
|
|
Shinya Kitaoka |
120a6e |
TTwainData.DSM_Entry = 0;
|
|
Shinya Kitaoka |
fd19c4 |
}
|
|
Shinya Kitaoka |
120a6e |
return (TTWAIN_GetState() >= TWAIN_SM_LOADED);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/*---------------------------------------------------------------------------*/
|
|
Shinya Kitaoka |
120a6e |
int TTWAIN_UnloadSourceManagerPD(void) {
|
|
Shinya Kitaoka |
120a6e |
if (TTWAIN_GetState() == TWAIN_SM_LOADED) {
|
|
Shinya Kitaoka |
120a6e |
if (hDSMLib) {
|
|
Shinya Kitaoka |
120a6e |
FreeLibrary(hDSMLib);
|
|
Shinya Kitaoka |
120a6e |
hDSMLib = NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
TTwainData.DSM_Entry = NULL;
|
|
Shinya Kitaoka |
120a6e |
TTWAIN_SetState(TWAIN_PRESESSION);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return (TTWAIN_GetState() == TWAIN_PRESESSION);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/*---------------------------------------------------------------------------*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef __cplusplus
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#endif
|