My problem is solved, Actually the problem wasn't on DataModule but it was I couldn't Catch any ComPort events in the Dll project, Finally I knew I must use a loop and check continual until I can take the value I expected it.
I put the correct code here,
Thank you all.
library VoteService;
uses
System.SysUtils, DateUtils,
System.Classes,
Extra in 'Extra\Extra.pas',
Un_Dm in 'DataModule\Un_Dm.pas' {DM: TDataModule},
CPort in 'CPort\CPort.pas';
{$R *.res}
function getVote(personnelCode:Pchar; docCode: Pchar; waitSecound : Integer):Integer; stdcall;
var
intStatus, intIdentifier: Integer;
strStatus_message: string;
Port: TPort;
StopBits: TStopBits;
Parity: TParityBits;
DataBits: TDataBits;
BaudRate: TBaudRate;
s : string;
tmpTime : TTime;
begin
Answer := 0;
SerialPortSetting(Port, StopBits, Parity, DataBits, BaudRate);
dm := TDM.Create(nil);
try
DM.ComPort1.Port := Port;
DM.ComPort1.StopBits := StopBits;
DM.ComPort1.Parity.Bits := Parity;
DM.ComPort1.DataBits := DataBits;
DM.ComPort1.BaudRate := BaudRate;
DM.ComPort1.Connected := True;
DM.ComPort1.WriteStr('*');
DM.ComPort1.Close;
DM.ComPort1.Open;
tmpTime := Now;
s := '';
repeat DM.ComPort1.ReadStr(s, len);
until (SecondsBetween(Now, tmpTime) > waitSecound) or (length(s)>0);
if s = '' then
Result := 0
else
Result := StrToInt(s);
finally
dm.Free;
end;
end;
exports
getVote;
begin
end.