TCHAR szText[255];
BOOL ret = FALSE;
CMN_ERROR Error;
CMN_ERROR Error_1;
DWORD dPropVal = NULL;
DWORD pdwBlobLen[65536];
PVOID pBuf = NULL;
PVOID pPCode = (PVOID)65536;
DWORD dwCode = 65536;
TriggerType tt = NotDefined;//NotDefined;
pBuf = malloc(65535); // alloc memory
pPCode = (char *)pBuf;
MyDMEnumOpenedProjects(); // open the DM and set the g_szProjectFile
memset(&Error, 0, sizeof(CMN_ERROR));
ret = PDLCSGetAction(/*PROJ_PATH*/g_szProjectFile,
"NEWPDL0.PDL", "IOField1", "ForeColor", (LPVOID)&dPropVal, &pPCode, (LPDWORD)1,
tt, malloc, &Error);
Как правильно вызвать функцию PDLCSGetAction в ODK?
Код:
BOOL PDLCSGetAction (
LPCTSTR lpszProjectName,
LPCTSTR lpszPictureName,
LPCTSTR lpszObjectName,
LPCTSTR lpszPropertyName,
LPDWORD pdwBlobLen,
LPVOID* ppvAction,
LPDWORD pdwFlags,
enum TriggerType Trigger,
LPVOID (*pfnAlloc)( size_t ),
PCMN_ERROR pError );
Description
This function inquires the P code of a C action linked to an object property.
Parameters
lpszProjectName
Pointer to the name of the project including path and name extension.
lpszPictureName
Pointer to the name of the picture, without the path, but including the name extension. Sensitive to upper and lower case letters.
lpszObjectName
Pointer to the name of the object
lpszPropertyName
Pointer to the name of the object property.
In order to read the C action of an event, this pointer must be NULL.
pdwBlobLen
Pointer to a tag returning the length of the code in bytes.
ppvAction
Address of a pointer returning the address of the C action code. The buffer for the code is allocated by the function.
The pointer can be used as parameter after casting on LPACTION in the script programming routines.
pdwFlags
Pointer to a tag which returns the flags identifying the type of the code provided:
AP_AKT_OBJ_PCODE
compiled P code.
AP_AKT_OBJ_NO_PCODE
source code.
Trigger
Type of the trigger definition within the object. The enumTriggerType is defined in the "trigger.h" file.
NotDefined
(must be set in order to read out the dynamic dialog of a property)
MouseClick
MouseLButtonDown
MouseLButtonUp
MouseRButtonDown
MouseRButtonUp
KeyboardDown
KeyboardUp
ObjectChange
PropertyChange
PropertyStateChange
PictureOpen
PictureClose
ObjectDefined
FocusEnter
LastTriggerType
ObjSpecificTriggerStart
= 0x1000
In order to access internal user object events by means of the TriggerID (possible with WinCC Version V5.0 or higher) it is required to add to the ObjSpecificTriggerStart constant the object index (1 - n) of the corresponding sequence, like in the PropertySheet under the "Object events" entry.
pfnAlloc
Pointer to a function of the calling application in order to allocate memory for the code of the C action.
pError
Pointer to the data of the extended error message within the CMN_ERROR structure. In the event of an error, the system writes error information to this structure.
Return Value
TRUE
P code has been determined.
FALSE
Error
Comments
The memory allocated must be cleared by the calling application.
The table below shows how to procede when assigning values to the szPropertyName and Trigger parameters in order to set a specific action type.
szPropertyName
Trigger
Action type
<> NULL
"NotDefined"
Assignment action
= NULL
"MouseClick"
"MouseLButtonDown"
"MouseLButtonUp"
"MouseRButtonDown"
"MouseRButtonUp"
""KeyboardDown"
"KeyboardUp"
Action on the object
= NULL
<> NULL
<> NULL
"ObjectChange"
"PropertyChange"
"PropertyStateChange"
Property/status change
With the exception of the default triggers, such as a mouseclick or keyboard event, a call with szPropertyName not equal to NULL and trigger = "PropertyChange" also works with OCX objects.
LPCTSTR lpszProjectName,
LPCTSTR lpszPictureName,
LPCTSTR lpszObjectName,
LPCTSTR lpszPropertyName,
LPDWORD pdwBlobLen,
LPVOID* ppvAction,
LPDWORD pdwFlags,
enum TriggerType Trigger,
LPVOID (*pfnAlloc)( size_t ),
PCMN_ERROR pError );
Description
This function inquires the P code of a C action linked to an object property.
Parameters
lpszProjectName
Pointer to the name of the project including path and name extension.
lpszPictureName
Pointer to the name of the picture, without the path, but including the name extension. Sensitive to upper and lower case letters.
lpszObjectName
Pointer to the name of the object
lpszPropertyName
Pointer to the name of the object property.
In order to read the C action of an event, this pointer must be NULL.
pdwBlobLen
Pointer to a tag returning the length of the code in bytes.
ppvAction
Address of a pointer returning the address of the C action code. The buffer for the code is allocated by the function.
The pointer can be used as parameter after casting on LPACTION in the script programming routines.
pdwFlags
Pointer to a tag which returns the flags identifying the type of the code provided:
AP_AKT_OBJ_PCODE
compiled P code.
AP_AKT_OBJ_NO_PCODE
source code.
Trigger
Type of the trigger definition within the object. The enumTriggerType is defined in the "trigger.h" file.
NotDefined
(must be set in order to read out the dynamic dialog of a property)
MouseClick
MouseLButtonDown
MouseLButtonUp
MouseRButtonDown
MouseRButtonUp
KeyboardDown
KeyboardUp
ObjectChange
PropertyChange
PropertyStateChange
PictureOpen
PictureClose
ObjectDefined
FocusEnter
LastTriggerType
ObjSpecificTriggerStart
= 0x1000
In order to access internal user object events by means of the TriggerID (possible with WinCC Version V5.0 or higher) it is required to add to the ObjSpecificTriggerStart constant the object index (1 - n) of the corresponding sequence, like in the PropertySheet under the "Object events" entry.
pfnAlloc
Pointer to a function of the calling application in order to allocate memory for the code of the C action.
pError
Pointer to the data of the extended error message within the CMN_ERROR structure. In the event of an error, the system writes error information to this structure.
Return Value
TRUE
P code has been determined.
FALSE
Error
Comments
The memory allocated must be cleared by the calling application.
The table below shows how to procede when assigning values to the szPropertyName and Trigger parameters in order to set a specific action type.
szPropertyName
Trigger
Action type
<> NULL
"NotDefined"
Assignment action
= NULL
"MouseClick"
"MouseLButtonDown"
"MouseLButtonUp"
"MouseRButtonDown"
"MouseRButtonUp"
""KeyboardDown"
"KeyboardUp"
Action on the object
= NULL
<> NULL
<> NULL
"ObjectChange"
"PropertyChange"
"PropertyStateChange"
Property/status change
With the exception of the default triggers, such as a mouseclick or keyboard event, a call with szPropertyName not equal to NULL and trigger = "PropertyChange" also works with OCX objects.
Код:
Код:
First-chance exception at 0x77124e97 in Apiw2.exe: 0xC0000005: Access violation reading location 0x00000001.
First-chance exception at 0x7c812afb in Apiw2.exe: Microsoft C++ exception: COleException at memory location 0x022efad0..
First-chance exception at 0x7c812afb in Apiw2.exe: Microsoft C++ exception: COleException at memory location 0x022efc24..
First-chance exception at 0x7c812afb in Apiw2.exe: Microsoft C++ exception: COleException at memory location 0x022efad0..
First-chance exception at 0x7c812afb in Apiw2.exe: Microsoft C++ exception: COleException at memory location 0x022efc24..
dword _flags=1;
lpdword flags=&_flags;
и в функцию передавай flags
Второй код вообще гениальный.
Не знаю как сейчас, но раньше чтоб воспользоваться функцией из билиотеки нужно было её загрузить в адресное пространство своего процесса, потом получить адрес этой функции, и лиш потом вызывать функцию
И когда будете искать функцию не забывайте про декорирование имён
QWERYTY, да я ошибся это не в библиотеке, а в справке такая информация о ней, а про адресное пространство не очень понял, но думаю не в этом дело, т.к. другие функции этой же библиотеки выполняются правильно, а эта при использовании выдает ошибку
LPDWORD это указатель (адрес) правильней будет (LPDWORD)&1
arrjj, пишет "Pdl01.cpp(733) : error C2101: '&' on constant", я думаю, что ошибка в передаче переменной "(LPVOID)&dPropVal", она тут самая важная и в нее должен как раз возвращаться исходный код action'a, но как по другому этот аргумент передать не знаю
arrjj, спасибо ОГРОМНОЕ, знаю что коментами нельзя благодарить, но этот ответ от больших проблем избавил:-)
Цитата: arrjj
тогда так:
dword _flags=1;
lpdword flags=&_flags;
и в функцию передавай flags
dword _flags=1;
lpdword flags=&_flags;
и в функцию передавай flags
А что сразу в функцию нельзя передавать &_flags? Больно много у автора выкрутасов с кастованием.
Вы заполняйте то что требует функция. Если функция пишет что ей нужен Pointer(указатель) это вовсе не значит что нужно начинать чудить