18.06.2005, 15:30 | #1 |
Moderator
|
WinAPI::getLastError()
День Добрый!
Хотел разобраться с расшифровкой числа которое возвращает WinAPI::getLastError Нашел: US-312-915-VPC4 WinAPi::getLastError() always returns 0 The problem was that the GetLastError value was set by Windows each time Windows API function was called. So, the reason that the X++ WinAPI::getLastError method wasn't able to pick up the correct error value, was that the kernel calls several Windows API functions between the X++ call to WinAPI::findFirstFile and WinAPI::getLastError, thus the GetLastError value was reset by Windows. This error was corrected - the kernel caches the GetLastError value right after a function call into a DLL and makes the value accessible from X++ via the DLL system class. Corrections needed: dllclass.hpp: Add a method to the classDLL class: int kcLastDLLError(interpret *ip); dllclass.cpp: Add int classDLL::kcLastDLLError(interpret *ip) { return ip->setIntReturnVal(LOCAL_SESSION_PBLK->_lastDLLError); } Add to classDLL::classDLL addMemberFunc(pType(DB_INT),"lastDLLError", QUALIFIER_STATIC | QUALIFIER_PROPERTY, (classStatic)&classDLL::kcLastDLLError); Change xDLLFunc::kcCall to { if (ip->getNumberOfArgs() != _numargs) // illegal number of arguments return ip->CQLRunError(CQL_ERR_FUNCARG2); int ret = CallDLLFunction(_dllfunc, _numargs, _argtypes, _rettype, ip, _dll->dllName(), _name); LOCAL_SESSION_PBLK->_lastDLLError = GetLastError(); return ret; } csesrv.hpp: Add a member to the SesPblk_t struct: public: DWORD _lastDLLError; X++ : WinAPI::getLastError: client server static int getLastError() { return DLL::lastDLLError(); } Вопрос с рашифровкой остался открытым. |
|
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|