我把参数传到一个prodedure 去执行,可是出错了,我看了好几遍了,大家帮忙
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,smpp_proUit, IdWinsock;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
ptest = ^TTest;
TTest = packed record
a :longword;
b :byte;
c :array[0..20] of char;
end;
procedure setTest(var test:TTest;
a:longword;
b:byte;
c:string);
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure setTest( var test:TTest;
a:longword;
b:byte;
c:string);
begin
test.a := a;
test.b := b;
fillchar(test.c,sizeof(test.c),0);
StrPCopy(test.c,c);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
pObj:pSmpp_submit;
sequenceId:LongWord;
len:LongWord;
strMsg:string;
begin
new(pObj);
sequenceId := 99;
len := sizeof(Tsmpp_submit);
strMsg := 'test';
assemble_Submit( pObj^,
len,
SMPP_SUBMIT,
44,
'fdas',
'138',
140,
strMsg);
end;
end.
第二个文件:
unit smpp_proUit;
interface
uses
IdWinsock , SysUtils ,Dialogs;
const
Content_len = 140;
SMPP_CONNECT: LongWord = $00000001;
SMPP_CONNECT_RESP: LongWord = $80000001;
SMPP_SUBMIT: LongWord = $00000004;
SMPP_SUBMIT_RESP: LongWord = $80000004;
SMPP_DELIVER: LongWord = $00000005;
SMPP_DELIVER_RESP: LongWord = $80000005;
SMPP_ACTIVE_TEST: LongWord = $00000008;
SMPP_ACTIVE_TEST_RESP: LongWord = $80000008;
Result1:LongWord =$00000000;
type
psmpp_Head = ^Tsmpp_Head;
Tsmpp_Head = packed record
Total_Length: LongWord; //消息总长度(含消息头及消息体)
Command_ID: LongWord; //命令或响应类型
Sequence_ID: LongWord; //消息流水号,顺序累加,步长为1,循环使用(一对请求和应答消息的流水号必须相同)
end;
Psmpp_submit_body = ^Tsmpp_submit_body;
Tsmpp_submit_body = packed record
EnterPriseId : array[0..19] of char;
Dest : array[0..19] of char;
Content_len : byte;
Content: array[0..Content_len-1] of char;
end;
Psmpp_submit = ^Tsmpp_submit;
Tsmpp_submit = packed record
head : Tsmpp_Head;
body : Tsmpp_submit_body;
end;
procedure assemble_Submit(var SmppObj:Tsmpp_submit;
len:LongWord;
CommandID:LongWord;
SequenceID:LongWord;
EnterpriseId:string;
Dest:string;
MsgLen:byte;
Content:string);
implementation
procedure assemble_Submit( var SmppObj:Tsmpp_submit;
len:LongWord;
CommandID:LongWord;
SequenceID:LongWord;
EnterpriseId:string;
Dest:string;
MsgLen:byte;
Content:string);
begin
SMPPObj.head.Total_Length := htonl(len);
SMPPObj.head.Command_ID := htonl(CommandID);
SMPPObj.head.Sequence_ID := htonl( SequenceID);
fillchar(SMPPObj.body.EnterPriseId,sizeof(SMPPObj.body.EnterPriseId),0);
StrPCopy(SMPPObj.body.EnterPriseId,EnterpriseId);
fillchar(SMPPObj.body.Dest,sizeof(SMPPObj.body.Dest),0);
StrPCopy(SMPPObj.body.Dest,Dest);
SMPPObj.body.Content_len := MsgLen;
fillchar(SMPPObj.body.Content,sizeof(SMPPObj.body.Content),0);
StrPCopy(SMPPObj.body.Content,Content);
end;
end.
就是在这个地方出错的:
new(pObj);
sequenceId := 99;
len := sizeof(Tsmpp_submit);
strMsg := 'test';
assemble_Submit( pObj^,
len,
SMPP_SUBMIT,
44,
'fdas',
'138',
140,
strMsg);
系统的提示是:
access voiv access violation at address 00000000
相关推荐
用js通过url传参把数据从一个页面传到另一个页面
用js把数据从一个页面传到另一个页面的层里? 如果是传到新页面的话,你网站基于什么语言开发直接用get或者post获取,然后输出到这个层 通过url传参 如果是HTML页面的话JS传到新页面就[removed].href=’a.html?id=100′;然后a.html页面的JS就<div id=”s”></div> [removed] document.getElementById(s)[removed]=[removed].split('?')[1]; [removed] 如果是想要实现AJAX在a页面传参数到b页面并且在a页面的层显示b页面执行参数的结果的话
mysql 批处理文件出错后继续执行的实现方法
下面小编就为大家带来一篇mysql 批处理文件出错后继续执行的实现方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
将本地已有的一个项目上传到新建的git仓库的方法
一、 克隆+拷贝 直接用把远程仓库拉到本地,然后再把自己本地的项目拷贝到仓库中去。然后push到远程仓库上去即可。此方法适用于本地项目不是一个git仓库的情况。 1、首先克隆 git clone git@github.com:*******.git 2、然后复制自己项目的所有文件到刚刚克隆下来的仓库中 3、最后push到远程仓库上面去: git push -u origin master 二、 强行合并两个仓库 先将本地的项目初始化为一个git仓库,然后再强行合并本地仓库和远程仓库,由于这两个仓库是完全不同的两个仓库,所以直接pull都会报错,需要在pull的时候假加上–allow-unr
windows下写的shell脚本在linux执行出错的解决办法
在Windows下写了一个shell脚本,上传到Linux下执行时报错: 代码如下:[root@localhost test]# ./test.sh -bash: ./test.sh: /bin/sh^M: bad interpreter: No such file or directory test.sh源码: 代码如下:#!/bin/sh echo “test shell “ 由于自己对shell不太熟悉,找同事沟通了后了解了原委,主要原因是test.sh是我在windows下编辑然后上传到linux系统里执行的。.sh文件的格式为dos格式。而linux只能执行格式为unix格
Jmeter命令行执行脚本如何设置动态参数
主要介绍了Jmeter命令行执行脚本如何设置动态参数,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下


网络通信/分布式开发

