안녕하세요 ?
델파이를 시작 한지 며칠 안되는 초보입니다.
지금 초보 주제에 .. ActiveX 랑 DLL 을 해보고 있는데요
ActiveX 파라메터로 WideStrnig 을 받아서요 이걸 PChar 로 바꾸어서
DLL 파라메터로 주고 싶은데 아무리 해도 변환이 잘 안되네요
그냥 PChar( WideString)했더니 한글 다깨지구여.
ShowMessage('PCHAR번환['+WideCharLenToString(PWideChar(inStrParam),Integer(inStr))+']');
이런식으로 해도 에러만 나고..
쉽게 바꾸는 방법이 있을듯 한데 초보라 뭐가 있는지 잘 모르겠네요 ^^:
그럼 답변 부탁드립니다. 좋은 하루 되세요.
가령
var
wstrOriginal :WideString;
strNew :string;
begin
wstrOriginal := <passed WideString value>;
strNew := wstrOriginal;
<function call needing PChar>(...., PChar(strNew));
....
end;
이런 식으로요...
지금 상황을 보니까, WideString은 얻어 있는 상태고,그값을 적당히 바꿔서 DLL-exported 함수에 PChar 형태로 전달하려고 하시는 거 같으니까... 메모리에 복사해 놓고 PChar 보내시면 될 듯 하군요...
아마.. 이렇게...
procedure Call_DLLProc_With_WideString_Returned_By_ActiveX(
a_PassedWideString :WideString);
var
strTemp :string;
arTemp :array [0..1023] of Char;
begin
...
ZeroMemory(@arTemp[0], SizeOf(arTemp));
strTemp := a_PassedWideString;
StrPCopy(@arTemp[0], strTemp);
DLL_Exported_Function(..., PChar(@arTemp[0], ...);
...
end;