Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

returning a char, in a Com method

DemoDemo Member Posts: 12
Hello everybody,

actually I'am writing a ATL COM Server who will contain method use form reading, and getting info about, an AudioCD.

My problem was when I write the method who return the current track position, the mciSendString command return my a char, but how can I return this value to my ComClient.

Can somebody help me...

Here is my code...

STDMETHODIMP CAudioCd::GetCurrentTrackPosition(DON'T_KNOW_THE_TYPE *out_trackPosition)
{
// TODO: Add your implementation code here
char position[12] = "00:00:00:00";

mciSendString("status playcd position", position, sizeof(position), NULL);

out_trackPosition = thePosition;

return S_OK;
}

Thanks for help

Demo


Comments

  • darioajrdarioajr Member Posts: 1
    : Hello everybody,
    :
    : actually I'am writing a ATL COM Server who will contain method use form reading, and getting info about, an AudioCD.
    :
    : My problem was when I write the method who return the current track position, the mciSendString command return my a char, but how can I return this value to my ComClient.
    :
    : Can somebody help me...
    :
    : Here is my code...
    :
    : STDMETHODIMP CAudioCd::GetCurrentTrackPosition(DON'T_KNOW_THE_TYPE *out_trackPosition)
    : {
    : // TODO: Add your implementation code here
    : char position[12] = "00:00:00:00";
    :
    : mciSendString("status playcd position", position, sizeof(position), NULL);
    :
    : out_trackPosition = thePosition;
    :
    : return S_OK;
    : }
    :
    : Thanks for help
    :
    : Demo
    :
    :
    :
    Use in your interface [out,retval] to return value by method
    [id(?), helpstring("method GetCurrentTrackPosition")] HRESULT GetCurrentTrackPosition([out,retval] BSTR *out_trackPosition);

    in your code this

    STDMETHODIMP CAudioCd::GetCurrentTrackPosition(BSTR *out_trackPosition)
    {
    char position[12] = "00:00:00:00";
    mciSendString("status playcd position", position, sizeof(position), NULL);

    CString sRet = position;
    *out_trackPosition = sRet.AllocSysString(); //return BSTR or other method that create a BSTR

    return S_OK;
    }



Sign In or Register to comment.