而不是在Web方法本身(作为SOAP XML)中返回二进制流(MTOM/Base64编码),例如:
[WebMethod]
public byte[] Download(string FileName)
....
return byteArray;
Run Code Online (Sandbox Code Playgroud)
这种方法可以以某种方式响应(可能通过Server
对象)?:
Response.BinaryWrite(byteArray);
Run Code Online (Sandbox Code Playgroud)
伪:
[WebMethod]
public DownloadBinaryWrite(string FileName)
...
Response.BinaryWrite(byteArray);
Run Code Online (Sandbox Code Playgroud) 如果 DLL 已经签名而无需重新编译,我是否可以使用新证书(使用 Microsoft 的 SignTool)安全地签名 DLL 文件?
在我这样做之后,一切看起来都很洁净,但我想 100% 确定。
继续我的另一个问题: 如何从我的应用程序传递和检索内存流到/从DLL?
我用IStream
输入/输出编写了DLL .DLL使用IXMLDocument
(起初我认为与后续问题有关)测试它,它在主UI中运行良好.当我从工作线程调用DLL时出现问题.
DLL:
library MyDLL;
uses
Windows,
Variants,
SysUtils,
Classes,
AxCtrls,
ActiveX,
XMLDoc,
XMLIntf;
{$R *.res}
procedure Debug(V: Variant);
begin
OutputDebugString(PChar(VarToStr(V)));
end;
procedure DoProcess(InStream, OutStream: TStream);
var
Doc: IXMLDocument;
begin
InStream.Position := 0;
Doc := TXMLDocument.Create(nil);
Doc.LoadFromStream(InStream);
// plans to do some real work...
OutStream.Position := 0;
Debug('MyDLL DoProcess OK');
end;
function Process(AInStream, AOutStream: IStream): Integer; stdcall;
var
InStream, OutStream: TStream;
begin
try
InStream := TOleStream.Create(AInStream);
try
OutStream := TOleStream.Create(AOutStream);
try
DoProcess(InStream, OutStream); …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将DDetours
lib 移植到Delphi 5/7.不会编译的行具有以下模式:
procedure Decode_J(PInst: PInstruction; Size: Byte);
var
Value: Int64;
VA: PByte;
begin
...
VA := PInst^.VirtualAddr + (PInst^.NextInst - PInst^.Addr) // <- compiler error
Run Code Online (Sandbox Code Playgroud)
编译错误:
[Error] InstDecode.pas(882):运算符不适用于此操作数类型
PInst^.VirtualAddr, PInst^.NextInst, PInst^.Addr
都被声明为PByte
(PByte = ^Byte
)
我该怎么做才能解决这个问题?
编辑:
PInstruction
定义为:
TInstruction = record
Archi: Byte; { CPUX32 or CPUX64 ! }
AddrMode: Byte; { Address Mode }
Addr: PByte;
VirtualAddr: PByte;
NextInst: PByte; { Pointer to the Next Instruction }
OpCode: Byte; { OpCode Value …
Run Code Online (Sandbox Code Playgroud) 我有一个 Windows Media Player ActiveX 控件。我希望它与它的 parent 对齐TPanel
。
问题是,无论我尝试什么,WMP 控件始终设置为其初始大小,而无法调整其大小。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, XpMan, ExtCtrls, WMPLib_TLB;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
public
Panel: TPanel;
MP: TWindowsMediaPlayer;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Width := 450;
Height := 260;
Panel := TPanel.Create(Self);
Panel.Parent := Self;
Panel.Align := alClient;
MP := TWindowsMediaPlayer.Create(Self);
// MP.stretchToFit := True;
MP.Parent := Panel;
MP.Align := alClient; …
Run Code Online (Sandbox Code Playgroud) 如何使用 BorderStyle 制作表单(ShowModal)bsDialog
。但是仍然可以调整大小并具有关闭按钮(没有图标,最小化,最大化)?
我不需要它来显示尺寸手柄。
假设我TMemoryStream
需要传递给我的DLL并从DLL中获取TMemoryStream
(位图流).
我在想我的DLL会:
procedure Process(
InBuff: Pointer;
InBuffSize: Integer;
var OutBuff: Pointer;
var OutBuffSize: Integer
); stdcall;
Run Code Online (Sandbox Code Playgroud)
该InBuff
很容易(我认为).我通过TMemoryStream.Memory
和TMemoryStream.Size
.
问题是我如何OutBuff
在DLL中分配,并且调用者应用程序可以将其转换回TMemoryStream
以后释放该内存(由调用者应用程序)?
调用者将使用dynamic LoadLibrary
/ FreeLibrary
each DLL调用.
我非常想要一个示例代码.希望我不是太粗鲁.
注1:调用者应用程序不知道输出大小,并假设它不能指定MAX buff大小.
注2:我不确定我的DLL签名.如果我做错了,请原谅我.我正在寻找一种效果很好的模式(也许不仅适用于Delphi而且适用于C++/C#Calller以及=我的奖金)
我有代码显示特定DBGrid的搜索表单,该表单以另一种形式(调用者表单TSearchGridForm
)放置:
procedure TSearchGridForm.FormDeactivate(Sender: TObject);
begin
// Pseudo
if NewActiveControl <> CallerForm.DBGrid then
Close;
end;
Run Code Online (Sandbox Code Playgroud)
在TSearchGridForm
由呼叫者形式与活化.Show
(未模态),并且当它被停用我想关闭/隐藏它仅当新的现用控制<> CallerForm.DBGrid
.
只有当用户点击DBGrid
调用者表单时,搜索表单才会保持可见,否则我需要将其关闭.
我怎样才能做到这一点?
我有记录类型:
type
TIPInfo = record
IP,
HostName,
City,
Region,
Country,
Loc,
Org: WideString
end;
Run Code Online (Sandbox Code Playgroud)
函数返回记录数据:
function GetPublicIPInfo(var IPInfo: TIPInfo): Boolean;
begin
// initialize
FillChar(IPInfo, SizeOf(TIPInfo), 0);
// populate data
IPInfo.IP := GetVallue('ip');
IPInfo.HostName := GetVallue('hostname');
IPInfo.City := GetVallue('city');
// etc...
Result := IsOk;
end;
Run Code Online (Sandbox Code Playgroud)
呼叫者,召集者:
var
IPInfo: TIPInfo;
if GetPublicIPInfo(IPInfo) then... // use data
Run Code Online (Sandbox Code Playgroud)
它是var TIPInfo
通过调用初始化的正确方法FillChar
还是应该将每个字段设置为空字符串?来电者应该这样做吗?
此外,out
在案例中使用参数会更好吗(因为函数不读取数据)?
我有这种类型:
type
TFieldRec = array of record
FieldName: string;
Value: Variant;
DataType: TFieldType;
Data: Pointer;
end;
Run Code Online (Sandbox Code Playgroud)
和代码:
var
FR: TFieldRec;
SetLength(FR, 5);
Run Code Online (Sandbox Code Playgroud)
我的问题:是否保证每个记录元素都将使用默认值进行初始化?
'', Unassigned, ftUnknown, nil
Run Code Online (Sandbox Code Playgroud)
在调试器中我可以看到它是真的.但我记得记录应该用Initialize
(或者是Finalize
?)初始化