| Subject: | Invalid pointer in simple API call with nils to pointers! |
| Posted by: | Fred Decker |
| Date: | Sun, 30 Nov 2008 |
It must be something simple and I'm pulling my hair out. I can not get this function to work. I always recieve _INVALPOINTER as the negative result code back from the function.
Here is the definition of my function:
function lineForward(
hLine,
bAllAddresses,
dwAddressID: Integer;
lpForwardList: pTLineForwardList;
dwNumRingsNoAnswer: Integer;
lphConsultCall: pLongInt;
lpCallParams: pTLineCallParams): Integer; StdCall;
Create an lpForwardList and call the function
var lpForwardList: pTLineForwardList;
line: integer; // defined ast pLongInt above, but wouldn't work here so changed it to just integer
lResult := GetLine(@line); // get the handle to the line, the handle works in another function
lResult := lineForward(line,0,0,lpForwardList,0,0,nil) // set it using the parameters in lpForwardList
// this turns OFF forwarding but even with no pointers gives INVAL_POINTER error! I am using this to test since it should be the simplest form of the function without even having to do anything but pass it the integer value for "line" to tell it which line to shut off the forwarding feature:
lResult := lineForward(
line, //hLine
0, //bAllAddresses
0, //dwAddressID
nil, //lpForwardList
0, //dwNumRingsNoAnswer
nil, //lpConsultCall
nil); //lpCallParams
Since the above turns off the feature and doesn't even have a pointer, how can I be getting an invalid pointer error? The MSDN docs say that pointing to a nil for lpForwardlist turns off the feature. Could there be something wrong with "line", the handle to the line? It works in another routine though that relies on it to set some modes.
Here is the MSDN C++ definition:
LONG WINAPI lineForward(
HLINE hLine,
DWORD bAllAddresses,
DWORD dwAddressID, // if null, clears forward
LPLINEFORWARDLIST const lpForwardList,
DWORD dwNumRingsNoAnswer,
LPHCALL lphConsultCall, //optional
LPLINECALLPARAMS const lpCallParams //optional
);
The way I've created the types.
type
pTLineForward = ^TLineForward;
TLineForward = record
dwForwardMode,
dwCallerAddressSize,
dwCallerAddressOffset,
dwDestCountryCode,
dwDestAddressSize,
dwDestAddressOffset: Integer;
end;
pTLineForwardList = ^TLineForwardList;
TLineForwardList = record
dwTotalSize,
dwNumEntries: Integer;
ForwardList: array [1..1] of TLineForward; //or does this have to be [0..0]?
end;
And here is the function that returns the handle to the line:
function lineOpen(
hLineApp,
dwDeviceID: Integer;
lphLine: pLongInt; //defined as pLongInt here, but had to define it as Integer for it to work in the function below.
dwAPIVersion,
dwExtVersion,
dwCallbackInstance,
dwPrivileges,
dwMediaModes: Integer;
lpCallParams: pTLineCallParams): Integer; StdCall;
I open the line like this:
var line: Integer;
lResult := lineOpen(integer(lineApp), // conflicting types here, but this seems to fix it?
Device.ID,
@line,
tapiVersion, // dwAPIVersion
0, // dwExtVersion
0, //callback instance
LINECALLPRIVILEGE_MONITOR + LINECALLPRIVILEGE_OWNER,
LINEMEDIAMODE_INTERACTIVEVOICE,
nil)
Thanks for any help
Fred