Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

memory could not be written after API call

Status
Not open for further replies.

swilliams

Programmer
Aug 23, 2000
583
BM
I am making an API call as follows:

iSession = FedExAPIBeginSession(IP + Chr$(0), Val(port), UserName, passWord, 0, custProfile, Len(custProfile), ibufflen)

I have the VC++ header file and so have checked obvious things like correct variable types being passed, but I keep getting the error ".... memory could not be written".

Earlier (before the above line) I successfully call another API to initialise the library.

Does anyone know why this error is being generated???

Simon [sig][/sig]
 
This is an interesting problem, could you post the Declare statment and other suporting code?

Collin [sig][/sig]
 
Colin - and anyone else that may be able to help:

In VC++, there is the line:

typedef int session_t;

followed by various functions. The function that I am getting the error on is:

EXPORT EXTERN session_t STDCALL FedExAPIBeginSession P_((char *system, int port,
char *userId,
char *passWord,
int custProfile,
char *cBuf, int cBufLen,
int *actualRecvBufLen ));

which I have translated to the VB declare statement to be:

Public Declare Function FedExAPIBeginSession Lib "FedExApiClient" ( _
ByVal system As String, _
ByVal port As Integer, _
ByVal userId As String, _
ByVal passWord As String, _
ByVal custProfile As Integer, _
ByVal cBuf As String, _
ByVal cBufLen As Integer, _
ByVal actualRecvBufLen As Integer) As Integer

Then, I am calling the API by the following code:

Dim IP As String
Dim port As Integer
Dim UserName As String
Dim passWord As String
Dim custProfile As String
Dim iCustProfileLen As Integer
Dim ibufflen As Integer
Dim iSession As Integer

IP = "127.0.0.1"
port = 8190
UserName = String$(32, " ")
passWord = String$(32, " ")
custProfile = String$(255, " ")
iCustProfileLen = Len(custProfile)
ibufflen = 32000

iSession = FedExAPIBeginSession(IP + Chr$(0), Val(port), UserName, passWord, 0, custProfile, Len(custProfile), ibufflen)

and it is on this last line that I am getting the GPF.

Simon [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top