here code.
char bpp[5]; int result, err; result = getprivateprofilestringa("abc", "cba", null, bpp, 5, "d:\\aefeaf.ini"); // result = 0 result = _get_errno(&err); // result = 0, err = 0 result = getlasterror(); // result = 0 and description msdn: in event initialization file specified lpfilename not found, or contains invalid values, function set errorno value of '0x2' (file not found). retrieve extended error information, call getlasterror.
last parameter random, file not existed. getlasterror() still return 0. explain me why didn't return 2?
edit: @jochenkalmbach suggest, ensure project not using c++/cli. , @claptrap said errorno typo (it should errno), add _get_errno code above. still, error code return 0. appreciated.
hopefully not using c++/cli... mess value of "getlasterror" because code internally uses "ijw" (it works) , bunch of win32 operations....
for native applications, works expected:
#include <stdio.h> #include <tchar.h> #include <windows.h> #include <crtdbg.h> int _tmain(int argv, char *argc[]) { char szstr[5]; int result = getprivateprofilestringa("abc", "cba", null, szstr, 5, "d:\\aefeaf.ini"); _asserte(result == 0); result = getlasterror(); _asserte(result == 2); } if using c++/cli, should surround method with
#pragma managed(push, off) // place method here #pragma managed(pop);
Comments
Post a Comment