SendMessage的返回值问题!(100分)

  • 主题发起人 主题发起人 gdxkz
  • 开始时间 开始时间
G

gdxkz

Unregistered / Unconfirmed
GUEST, unregistred user!
char *name = SendMessage(hwnd_winamp, WM_USER, index, IPC_GETPLAYLISTFILE);<br>上面是C中的返回值,但Delphi的SendMessage好象所有的消息返回都是integer型,难道就不能返回其他的类型了,或者需要自己声明window原来的SendMessage?
 
返回值不一定必须是整型啊!<br>你可以自己依据发送的消息进行定义的!<br><br>&nbsp; The return value specifies the result of the message processing and <br>depends on the message sent.
 
你在Delphi中打入SendMessage发送WM_USER消息让DELPHI进行参数提示看看,提示的返回值是INTEGER,我用的是DELPHI6
 
char * =&gt;指针 =&gt;整数<br><br>是一回事!
 
我试过使用很多种方法都不能还原name这个字串,该怎么做才能还原SendMessage返回的字符串?
 
pchar()就可以了。
 
下面是在WINAMP主页上的TIP,我还是无法得到正确的结果。<br>How do I get the filename (not title) of the current song?<br>First you must get the current track index from the playlist. Then you can get the filename. <br><br>#define IPC_GETLISTPOS 125<br>#define IPC_GETPLAYLISTFILE 211<br>int index = SendMessage(hwnd_winamp, WM_USER, 0, IPC_GETLISTPOS);<br>char *name = SendMessage(hwnd_winamp, WM_USER, index, IPC_GETPLAYLISTFILE);<br><br>
 
奇怪,可以得到Index,没有办法得到Song Title?
 
就是!下面的例子在delphi里也不行。<br>Here is some sample code to add a song to the playlist. <br>#define &nbsp;IPC_PLAYFILE 100;<br>COPYDATASTRUCT cds;<br>cds.dwData = IPC_PLAYFILE;<br>cds.cbData = lstrlen(filename) + 1;<br>cds.lpData = (void *) filename;<br>SendMessage(hwnd_winamp, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&amp;cds);<br><br>我转成delphi后也不行,总感觉DELPHI的SendMessage和其他语言的不一样!<br>var<br>&nbsp;cds:COPYDATASTRUCT;<br>&nbsp;f:pchar;<br>begin<br>cds.dwData:=100;<br>cds.cbData:= length(filename) + 1;<br>cds.lpData:= lstrcpy(f,pchar(filename));<br>SendMessage(hwndWinamp, WM_COPYDATA, 0, cds);<br>end;
 
var<br>&nbsp;cds:COPYDATASTRUCT;<br>&nbsp;f:pchar;<br>begin<br>cds.dwData:=100;<br>cds.cbData:= length(filename) + 1;<br>cds.lpData:= pchar(filename); &nbsp;// &nbsp;这样就可以了,你那样反而错<br>SendMessage(hwndWinamp, WM_COPYDATA, 0, cds);<br>end;
 
后退
顶部