Try this:
[DllImport("DJTTS.dll",CharSet=CharSet.Auto)]
public static extern short DJTTS_StartPlayText(short wChnlNo,StringBuilder pText,short size,short IsFemale);

解决方案 »

  1.   

    To Knight94(愚翁)和我前面写的代码效果是一样的,还有没有其他的写法
      

  2.   

    Try:[DllImport("DJTTS.dll",CharSet=CharSet.Auto)]
    public static extern short DJTTS_StartPlayText(short wChnlNo,[in,out] char pText,short size,short IsFemale);or[DllImport("DJTTS.dll",CharSet=CharSet.Auto)]
    public static extern short DJTTS_StartPlayText(short wChnlNo,[out] char pText,short size,short IsFemale);
    BTW,what is wChnlNo?
      

  3.   

    [Out, MarshalAs(UnmanagedType.TBStr)] out char pTextYou can refer to MSDN on the UnmanagedType and the use of [in] [out] paramenter's
    modifier.Hope it would help you.
      

  4.   

    To qimini(循序渐进)你能不能根据我前面写的帮我写出实际的代码,先谢过
      

  5.   

    To qimini(循序渐进)我已看到你写的代码了,但没有调用代码?BTW,what is wChnlNo?
    wChnlNo是一个通道号short型的,不用考虑它
      

  6.   

    To Knight94(愚翁)   先谢谢你能列出用其他方式调用过程吗?我不太明白你这个问题的意思?两种调用我都写上了啊
      

  7.   

    String welcome="XYZ";
    Tc08aLib.DJTTS_StartPlayText(0,welcome.ToCharArray()[0],(short)welcome.Length,1);
      

  8.   

    Try also(not pass in vs2003):StringBuilder welcome=new StringBuilder("XYZ");
    Tc08aLib.DJTTS_StartPlayText(0,welcome.Chars[0],(short)welcome.Length,1);
      

  9.   

    VS2003 Pass:StringBuilder welcome=new StringBuilder("XYZ");
    Tc08aLib.DJTTS_StartPlayText(0,welcome[0],(short)welcome.Length,1);
      

  10.   

    To qimini(循序渐进) 
    兄弟们真是倾力相助了你写的两种方法都试过了还是不行?怎么办啊?
      

  11.   

    我的意思是:你有用C调用此Dll的代码吗?或者其他编程工具?
      

  12.   

    [DllImport("DJTTS.dll",CharSet=CharSet.Ansi)]
    public static extern int DJTTS_StartPlayText(short wChnlNo,[MarshalAs(UnmanagedType.LPStr)]string pText, int size, int IsFemale);
      

  13.   

    上面的方法我都试了,不行下面是在VC++6下的调用代码,这段代码运行时是正常的LPTSTR welcome = "语音测试";
    DJTTS_StartPlayText(0,welcome,strlen(welcome),1);
      

  14.   

    [DllImport("DJTTS.dll",CharSet=CharSet.Auto)]
    public static extern int DJTTS_StartPlayText(short wChnlNo, string pText, int size, int IsFemale);
      

  15.   

    TO: qqchen79(知秋一叶 [MS MVP])    这种方法我也试过了,不行
      

  16.   

    另外比较重要的一点,这个函数是单字节的
    所以 VC++下 LPTSTR welcome = "语音测试"; 正确
    LPSTR welcome = "语音测试"; 也同样正确