What is Error number 3?

Windows specific forum
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

What is Error number 3?

Post 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
Windows 7 & PureBasic 4.4
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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 
BERESHEIT
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

Thanks, very useful snippet :D
Windows 7 & PureBasic 4.4
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Post by akj »

I think the original source of ShowAPIError() is:
http://www.purebasic.fr/english/viewtopic.php?t=21432
Anthony Jordan
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post 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
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Post Reply