Am I able to avoid a GPF or other crash if someone passes an invalid value to my Function?
For Example if I have a DLL and it appears as
If another programming language passes a +2,147,483,648 (1 one over the PB Long definition) can I do something like
or am I already hosed because the parameter was passed and its a matter of time that a GPF or other crash may or may not occur?
Reason I ask is, all too often in my earlier days (and probably still now), me and a few others have always "Butted Heads" as to porting code from one language to another, and how it is DEFINITELY NOT "Verb for Verb" (aka a LONG my not mean a LONG in another programming language)
Usually, its me trying to use someone else's DLL, but today its one where a user using Matlab calling my functions from MY DLL, but any function passing a parameter will cause a GPF or some error.
I did some poking around and from what I can find, Although the value is a whole number, the definition of "LONG" allows for decimal points (so for all I know he could be passing 3.0 to me and not 3)
From the bit I was able to look up from the 3rd party language, I could NOT find what the range of valid values were for them, but wonder if I can protect against this situation in my own dll?
any ideas?, or am I at the whim of M$?.....to this day I have know CLUE as to when a error occurs (as we all know calling another dll, the problem may not creep up till later)
For Example if I have a DLL and it appears as
Code:
DECLARE FUNCTION MyFunction(BYVAL MyNumber AS LONG) EXPORT AS LONG END FUNCTION
Code:
DECLARE FUNCTION MyFunction(BYVAL MyNumber AS LONG) EXPORT AS LONG SELECT CASE MyNumber CASE > 2,147,483,64 CASE < -2,147,483,648 CASE ELSE MSGBOX "Invalid Parameter" END SELECT END FUNCTION
Reason I ask is, all too often in my earlier days (and probably still now), me and a few others have always "Butted Heads" as to porting code from one language to another, and how it is DEFINITELY NOT "Verb for Verb" (aka a LONG my not mean a LONG in another programming language)
Usually, its me trying to use someone else's DLL, but today its one where a user using Matlab calling my functions from MY DLL, but any function passing a parameter will cause a GPF or some error.
I did some poking around and from what I can find, Although the value is a whole number, the definition of "LONG" allows for decimal points (so for all I know he could be passing 3.0 to me and not 3)
From the bit I was able to look up from the 3rd party language, I could NOT find what the range of valid values were for them, but wonder if I can protect against this situation in my own dll?
any ideas?, or am I at the whim of M$?.....to this day I have know CLUE as to when a error occurs (as we all know calling another dll, the problem may not creep up till later)
Comment