Page 1 of 1

What is Error number 3?

Posted: Sun Jun 24, 2007 2:21 pm
by milan1612
Hi guys,
I'm using the Preferences Lib of PB. When I create a preference file,
CreatePreferences() returns 0. GetLastError_() returns 3. Does anybody
know WTF error number 3 is?

EDIT: Solved, I found this link: http://msdn.microsoft.com/library/defau ... _codes.asp

Posted: Sun Jun 24, 2007 2:33 pm
by netmaestro
An easy way, for next time:

Code: Select all

ProcedureDLL.s ShowAPIError (CheckReturnValue) ; Forum code, unsure of original author
  Buffer.s      = Space (4096) 
  NumberOfChars = FormatMessage_(#FORMAT_MESSAGE_FROM_SYSTEM, 0, CheckReturnValue, 0, Buffer.s, Len(Buffer.s), 0) 
  ProcedureReturn Left (Buffer.s, NumberOfChars-2) 
EndProcedure 

Posted: Sun Jun 24, 2007 4:27 pm
by milan1612
Thanks, very useful snippet :D

Posted: Mon Jun 25, 2007 7:01 am
by akj
I think the original source of ShowAPIError() is:
http://www.purebasic.fr/english/viewtopic.php?t=21432

Posted: Thu Aug 09, 2007 10:18 pm
by Flype
another very short one :

Code: Select all

Macro LastErrorMessage() 
  Left(LastErrorMessage.s{4096}, FormatMessage_(#FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError_(), 0, @LastErrorMessage, 4096, 0) - 2)
EndMacro

Macro LastErrorMessageRequester() 
  MessageRequester("LastError", LastErrorMessage(), #MB_ICONERROR)
EndMacro