Official BS.Player forums  

Go Back   Official BS.Player forums > Main forum > General Talk And Support
Register FAQ Calendar Today's Posts Search

General Talk And Support General talk and peer-to-peer support about BS.Player and other video and audio multimedia players.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 8th June 2005
Junior Member
BS.Player Newbie
 
Join Date: Jun 2005
Posts: 3
Rep Power: 0
immortal is an unknown quantity at this point
Default BSP_GetFileName and VB 6

I'm trying to use the BSP_GetFileName routine in visual basic, however it always returns a buffer containing nothing but zeros. Here is the code I'm using:

Public Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As Long) As Long


Public Declare Function CopyDataSendMessage Lib "user32" Alias _
"SendMessageA" (ByVal WndID As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByRef lParam As COPYDATASTRUCT) As Long


Public Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" _
(ByVal lpString1 As String, ByVal lpString2 As String) _
As Long


Public Type COPYDATASTRUCT
dwData As Long
cbData As Long
lpData As Long

End Type


Public Const WM_COPYDATA = &H4A
Public Const BSP_GetFileName = &H1010B
Public bspClass As String
Public hWndBSPlayer As Long
Public RetVal As Long

Public Function BSGetCurrentFile() As String
Dim nullpos As Integer
bspClass = "BSPlayer"
hWndBSPlayer = FindWindow(bspClass, 0)
If hWndBSPlayer = 0 Then 'can't find BSPlayer
BSGetCurrentFile = ""
Exit Function
End If
Dim buffer As String * 256

Dim cds As COPYDATASTRUCT
cds.dwData = BSP_GetFileName
cds.lpData = lstrcpy(buffer, buffer)
' Copies filename to itself. Nothing happens, but returns the address for the pointer to the string!
cds.cbData = 4

RetVal = CopyDataSendMessage(hWndBSPlayer, WM_COPYDATA, Form1.hwnd, cds)
nullpos = InStr(buffer, Chr(0))
If nullpos > 1 Then BSGetCurrentFile = Left(buffer, nullpos - 1)

End Function

the code executes correctly and CopyDataSendMessage returns a value of 1 but the currently open filename isn't returned. I'm using BSPlayer Pro
Version 1.22 Build 817, 24. Feb 2005. I am using a very similar routine to open a file, and that works fine. Any help would be appreciated.
Reply With Quote
  #2 (permalink)  
Old 8th June 2005
Junior Member
BS.Player Newbie
 
Join Date: Jun 2005
Posts: 3
Rep Power: 0
immortal is an unknown quantity at this point
Default

Ok ignore the previous. I should have been using varptr to get a pointer to buffer and for some reason it doesn't work with a fixed length string.

However it now returns a value which contains only question marks followed by an I. eg. ????????????i. Having searched through previous posts I found that someone else is having the same problem. Does anyone have a fix?
Reply With Quote
  #3 (permalink)  
Old 8th June 2005
Moderator
BS.Player Master
 
Join Date: Nov 2003
Location: Italy
Posts: 3,037
Rep Power: 28
Tizio will become famous soon enough
Default

Can you post your routine to open a file?
Thanks

P.S. I'm trying to find a solution to this problem, but I have no time now... If I can resolve this I'll make you know!
__________________
BSP SkinMaker (v1.07) the one and only Skin Editor for BSplayer
BSP Definitions Manager (v1.02)
BS.Player's FAQ (by BSPeter) | Italian language file (v2.57 build 1051)
Reply With Quote
  #4 (permalink)  
Old 8th June 2005
Junior Member
BS.Player Newbie
 
Join Date: Jun 2005
Posts: 3
Rep Power: 0
immortal is an unknown quantity at this point
Default

Routine to open file as requested:

Public Sub BSPAddFile(filename As String)
' Adds a file to the playlist

hWndBSPlayer = FindWindow(bspClass, 0)
If hWndBSPlayer = 0 Then 'can't find BSPlayer
Exit Sub
End If

Dim cds As COPYDATASTRUCT
cds.dwData = BSP_OpenFile
cds.lpData = lstrcpy(filename, filename)
' Copies filename to itself. Nothing happens,
' but returns the address for the pointer to the string!
cds.cbData = Len(filename) + 1

RetVal = CopyDataSendMessage(hWndBSPlayer, WM_COPYDATA, 0&, cds)

End Sub
Reply With Quote
  #5 (permalink)  
Old 8th June 2005
BSPeter's Avatar
Moderator
BS.Player Master
 
Join Date: Nov 2002
Location: The Netherlands
Posts: 5,463
Rep Power: 33
BSPeter is on a distinguished road
Default

Is this post perhaps of any use to you?
__________________
Help2Help (click) BSplayer: simply the best & most versatile (Build 1072 Dutch language here!)
When posting always mention your computer's OS and the version and build number(!) of BS.Player as used by you,
as well as - if applicable and especially when encountering problems - the type(s) of the file(s) mentioned in your post.
Private messages/Visitor messages are NOT for seeking personal help with respect to BS.Player! Instead use the forums!
Reply With Quote
  #6 (permalink)  
Old 8th June 2005
Moderator
BS.Player Master
 
Join Date: Nov 2003
Location: Italy
Posts: 3,037
Rep Power: 28
Tizio will become famous soon enough
Default

Unfortunally it didn't help me... :(
But thanks for the link :)

Quote:
Originally Posted by immortal
...However it now returns a value which contains only question marks followed by an I. eg. ????????????i...
If the file extension terminates with "g" (for example file_name.mpg) the name returned is something like ????????????g, and if the file name is looong the name returned is composed only by "?".

@immortal
Thank you for providing the OpenFile code, my fault was that I used VarPtr instead of lstrcpy... :P
Thank you.

I hope someone will solve the retrive filename issue
__________________
BSP SkinMaker (v1.07) the one and only Skin Editor for BSplayer
BSP Definitions Manager (v1.02)
BS.Player's FAQ (by BSPeter) | Italian language file (v2.57 build 1051)
Reply With Quote
  #7 (permalink)  
Old 12th June 2005
Moderator
BS.Player Master
 
Join Date: Nov 2003
Location: Italy
Posts: 3,037
Rep Power: 28
Tizio will become famous soon enough
Default

I encountered other problems with the SendMessage call.
For BSP_GetSkin the behaviour is the same as for BSP_GetFileName.

Every time I send a seeking position to BSplayer with the BSP_Seek message, BSplayer seek bar moves to time 00:20:40.
The same behaviour for the BSP_SetVol message, but this time BSplayer goes to 100% Volume level.

No problems with BSP_GETVERSION, BSP_OpenFile (thanks to immortal), BSP_GetMovLen, BSP_GetMovPos, BSP_GetVol, BSP_SetSkin, BSP_LoadSub, BSP_LoadAudio, BSP_LoadPlaylist, BSP_LoadPlaylistInt and with all BSP_(action) actions.
The only Action I can't use is BSP_VolUp. When I send this action (BSP_VolUp=1) BSplayer does nothing.

With BSP_GetStatus I have a strange behaviour:
I get the STOP, PLAY and PAUSE status, but Instead of "No movie open" (value=4) I get value=-1 ....
__________________
BSP SkinMaker (v1.07) the one and only Skin Editor for BSplayer
BSP Definitions Manager (v1.02)
BS.Player's FAQ (by BSPeter) | Italian language file (v2.57 build 1051)
Reply With Quote
  #8 (permalink)  
Old 12th June 2005
Senior Member
BS.Player Power User
 
Join Date: Feb 2004
Posts: 126
Rep Power: 0
RafkeP is an unknown quantity at this point
Default

I don't know anything about VB, but I just want to report that I don't have problems using BSP_GetFileName with C++.
This does not solve your problem, but at least you know it's not a bug in BSplayer.

Rafke P.
Reply With Quote
  #9 (permalink)  
Old 13th June 2005
Moderator
BS.Player Master
 
Join Date: Nov 2003
Location: Italy
Posts: 3,037
Rep Power: 28
Tizio will become famous soon enough
Default

In fact I think it's a VB problem, or (maybe ONLY) our fault. It seems like the handle of the program is passed in a bad way (this is my conclusion after reading the post linked by BSPeter, and since the BSP_GetSkin and BSP_GetFileName commands are the only ones that require the program to send BSplayer its handle)... but I don't know why (I'm not a skilled programmer)

If anybody can tell me something about BSP_Seek and BSP_SetVol commands (if you Rafke want to try them, and maybe also BSP_GetStatus, in c++) I will know if it's a BSplayer or VB problem.

Thank you :)
bye
__________________
BSP SkinMaker (v1.07) the one and only Skin Editor for BSplayer
BSP Definitions Manager (v1.02)
BS.Player's FAQ (by BSPeter) | Italian language file (v2.57 build 1051)
Reply With Quote
  #10 (permalink)  
Old 13th June 2005
Senior Member
BS.Player Power User
 
Join Date: Feb 2004
Posts: 126
Rep Power: 0
RafkeP is an unknown quantity at this point
Default

Tizio,

I will try the other commands in the following days.

This is the way I send the message in C++ :
Code:
SendMessage(bsp_hand,WM_COPYDATA,WPARAM(appHWND),(LPARAM)&cds);
Notice that I'm typecasting (I believe that's what it's called...I'm a lousy programmer I just keep typing code until it works) the application handle and cds. Maybe you need to do that too.

I will report back on the other commands.
Rafke

EDIT: I just tried the GetStatus command and I can confirm the behaviour you're seeing : when no file is open the command returns -1

EDIT2: The SetVol command is working, but the volume slider on the skin doesn't follow.The volume, however, is set correctly.
Reply With Quote
  #11 (permalink)  
Old 14th June 2005
Moderator
BS.Player Master
 
Join Date: Nov 2003
Location: Italy
Posts: 3,037
Rep Power: 28
Tizio will become famous soon enough
Default

Thank you Rafke for your tests!!

Yes, it's typecasting (AFAIK), but I don't know how to cast a WPARAM in VB, have to search the web . For cds (I think) I don't need to typecast since it works ok with OpenFile and SetSkin...

For SetVol I have to try a different way, but I don't think it's the correct one :?.. we will see...

I'm "glad" to know that at least the GetStatus command doesn't work also with C++ (it's not my fault :) )

Thak you again :D
__________________
BSP SkinMaker (v1.07) the one and only Skin Editor for BSplayer
BSP Definitions Manager (v1.02)
BS.Player's FAQ (by BSPeter) | Italian language file (v2.57 build 1051)
Reply With Quote
  #12 (permalink)  
Old 14th June 2005
Moderator
BS.Player Master
 
Join Date: Nov 2003
Location: Italy
Posts: 3,037
Rep Power: 28
Tizio will become famous soon enough
Default

Ok, BSP_SetVol and BSP_Seek now work perfectly (my error was that I sent the address of the value and not the value itself to BSplayer :P ).
And I can confirm that the volume slider on the skin doesn't follow the volume level (and no OSD about volume changes are shown).

I tried typecasting my appHWND, but it didn't work :( ...
WPARAM is (in Win32 systems) a 32bit value passed as a parameter to a window procedure or callback function, and my appHWND (Form1.hWnd) is a Long value (4byte=32bit), but with value between -2.147.483.648 and 2.147.483.647, so I typecasted it to Single (4byte=32bit), which has values between -3,402823E38 and -1,401298E-45 for negative values and between 1,401298E-45 and 3,402823E38 for positive values (but since the handle has no decimals it's of no use typecating this way...).
BTW, the value sent to BSplayer is a 32bit value, the same as WPARAM typecasted values... and the handle value is correct (I checked it with other programs that retrieve the program handle)...

I have no more ideas :?

Now the only problematic commands are: BSP_GetSkin, BSP_GetFileName and BSP_VolUp.

Bye
__________________
BSP SkinMaker (v1.07) the one and only Skin Editor for BSplayer
BSP Definitions Manager (v1.02)
BS.Player's FAQ (by BSPeter) | Italian language file (v2.57 build 1051)
Reply With Quote
  #13 (permalink)  
Old 14th June 2005
Senior Member
BS.Player Power User
 
Join Date: Feb 2004
Posts: 126
Rep Power: 0
RafkeP is an unknown quantity at this point
Default

Today I tested GetSkin and VolUp.
Both work as they should. With the VolUp even the volume slider on the skin works.

I still have one idea left for you and the topicstarter:
maybe you are passing the wrong handle (all the rest looks OK to me).
Output the handle somewhere (in a textbox or something) and then check with another application.

@Tizio, since you know Girder you can use that to check the handle :
add a new command
go to targetting options and drag the crosshair to your application
check what handle corresponds to the result.

I know Girder is not made for these sort of things, but it was the first that came to mind. I tested it and it works, but feel free to use what you like.

Rafke
Reply With Quote
  #14 (permalink)  
Old 14th June 2005
Moderator
BS.Player Master
 
Join Date: Nov 2003
Location: Italy
Posts: 3,037
Rep Power: 28
Tizio will become famous soon enough
Default

Quote:
Originally Posted by Tizio
... and the handle value is correct (I checked it with other programs that retrieve the program handle)...
One of those programs is Girder, and the handle read by Girder is the same I send to BSplayer. I have checked which handle I send to BSplayer in debug mode and also with a textbox (obviously the value is the same) and it matches the one indicated in Girder...

Thank you anyway for the suggestion :)

VolDown works perfectly for me, and the volume slider moves while I change the volume value, but (I don't know why) VolUp doesn't work.
And I've noticed that also BSP_OpenSub = 62 doesn't work, while BSP_LoadSub works.... :shock:

:roll: I don't know what to do (I will pass to c++ when I will have more time :) )
__________________
BSP SkinMaker (v1.07) the one and only Skin Editor for BSplayer
BSP Definitions Manager (v1.02)
BS.Player's FAQ (by BSPeter) | Italian language file (v2.57 build 1051)
Reply With Quote
  #15 (permalink)  
Old 14th June 2005
Senior Member
BS.Player Power User
 
Join Date: Feb 2004
Posts: 126
Rep Power: 0
RafkeP is an unknown quantity at this point
Default

Oops, I missed that part. Sorry about that :oops:

For the moment I'm out of ideas too.
I will let you know when I think of something.
Reply With Quote
  #16 (permalink)  
Old 17th June 2005
Senior Member
BS.Player Power User
 
Join Date: Feb 2004
Posts: 126
Rep Power: 0
RafkeP is an unknown quantity at this point
Default

I don't know if this will make any sense (I had too much wine and know [censored] about VB), but maybe it helps.

Compare your code to the c++ code

Code:
cds.lpData = lstrcpy(buffer, buffer) 
' Copies filename to itself. Nothing happens, but returns the address for the pointer to the string!
If I understand correctly you put the adres of a pointer to buffer in lpData

Now here is the C++ code

Code:
adr=&buf;
cds.lpData=&adr;
Now if I understand this correctly (like I said before I don't know c++ either :D )

adr contains the adress of the pointer to buffer, but
lpData contains the adress of the pointer to the adres of the pointer to the buffer

I tried to fix it in VB6 and didn't succeed, but I hope this is somehow of use to you.

Rafke P.

EDIT:On a more sober note: this doesn't explain why the open file is working though.
Reply With Quote
  #17 (permalink)  
Old 21st June 2005
Moderator
BS.Player Master
 
Join Date: Nov 2003
Location: Italy
Posts: 3,037
Rep Power: 28
Tizio will become famous soon enough
Default

Thank you Rafke for the clues, but it seems I can't obtain the address of the variable (only the pointer to it).
And searching on the web I found bad behaviours with VB when you try to send API calls by sending the pointer or the address of a variable (plus VB uses UNICODE strings, instead of ANSI that are used for API calls, but neither canverting the string to ANSI works)...
I have an idea, maybe to read the portion of memory of the pointer sent to BSplayer, but I have no time at the moment..

(There are a lot of problems when the few things you know are self and quick learned :roll: and that is my VB knowledge)
__________________
BSP SkinMaker (v1.07) the one and only Skin Editor for BSplayer
BSP Definitions Manager (v1.02)
BS.Player's FAQ (by BSPeter) | Italian language file (v2.57 build 1051)
Reply With Quote
  #18 (permalink)  
Old 21st March 2007
Junior Member
BS.Player Newbie
 
Join Date: Mar 2007
Location: Romania
Posts: 1
Rep Power: 0
llai is an unknown quantity at this point
Default Re:BSP_GetFileName and VB 6

This the correct method.
Try it and tell me if it works.

Public Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As Long) As Long

Public Declare Function CopyDataSendMessage Lib "user32" Alias _
"SendMessageA" (ByVal WndID As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByRef lParam As COPYDATASTRUCT) As Long

Public Type COPYDATASTRUCT
dwData As Long
cbData As Long
lpData As Long
End Type

Public Const WM_COPYDATA = &H4A
Public Const BSP_GetFileName = &H1010B
Public bspClass As String
Public hWndBSPlayer As Long
Public RetVal As Long

Public Function BSGetCurrentFile() As String
Dim nullpos As Integer
bspClass = "BSPlayer"
hWndBSPlayer = FindWindow(bspClass, vbNullString)
If hWndBSPlayer = 0 Then 'can't find BSPlayer
BSGetCurrentFile = ""
Exit Function
End If
Dim buffer As String

Dim cds As COPYDATASTRUCT

buffer = Space$(256)
cds.dwData = BSP_GetFileName
cds.lpData = VarPtr(buffer)
cds.cbData = 4

RetVal = CopyDataSendMessage(hWndBSPlayer, WM_COPYDATA, Form1.hwnd, cds)
buffer = StrConv(buffer, vbUnicode)
nullpos = InStr(buffer, vbNullChar)
If nullpos > 1 Then BSGetCurrentFile = Left(buffer, nullpos - 1)
End Function
Reply With Quote
Reply

Tags
bspgetfilename


Posting Rules


All times are GMT +1. The time now is 11:20 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
Ad Management plugin by RedTyger

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20