Author |
Topic: Using DLL's (Read 931 times) |
|
MartinKing
New Member
member is offline


Posts: 2
|
 |
Using DLL's
« Thread started on: Jul 23rd, 2010, 4:48pm » |
|
I've only recently started playing with BBCB4W and as a "little" project I was looking at making a H.264 file splitter using a DLL from HIKVision (HikPlayM4.dll) The code I have so far is :-
SYS "LoadLibrary", @lib$+"HikPlayM4.dll" TO HikPlay% IF HikPlay% = 0 ERROR 100, "Cannot load HikPlayM4.dll" PRINT ~HikPlay% SYS "GetProcAddress", HikPlay%, "Hik_PlayM4_GetSdkVersion" TO `Hik_PlayM4_GetSdkVersion` SYS "GetProcAddress", HikPlay%, "Hik_PlayM4_GetCapsEx" TO `Hik_PlayM4_GetCapsEx` SYS "GetProcAddress", HikPlay%, "Hik_PlayM4_SetFileRefCallBack" TO `Hik_PlayM4_SetFileRefCallBack` REM Print version number (HEX) SYS `Hik_PlayM4_GetSdkVersion`, @hwnd% TO ver% PRINT ~ver% REM Print Primary display (0) capabilities (HEX) SYS `Hik_PlayM4_GetCapsEx`, 0 TO caps% PRINT ~caps% END
And when I run it I get sensible values displayed for both version and display capabilities. However I'm not sure how to implement "Hik_PlayM4_SetFileRefCallBack" . The documentation says :-
BOOL Hik_PlayM4_SetFileRefCallBack(LONG nPort, void ( _stdcall *pFileRefDone) (DWORD nPort,DWORD nUser),DWORD nUser);
Description: Registers a callback function to be called when the file index is created. When the file is opening, a index for this file will be created in background. It can improve the performance of the seeking. Because some functions need this index, you must call them after the index is created, it means that the callback function is called. Parameters: nPort [in] The channel of the player. It ranges from 0 to PLAYM4_MAX_SUPPORTS-1. SetFileRefCallBack [in] Address of a function to be called. nUser [in] user data. Description of the callback function : void FileRefDone(DWORD nPort,DWORD nUser)
Parameter : nPort the channel of the player. nUser user data.
Admittedly this is probably a fairly ambitious project and I'm not sure if it's even something that can realistically be done in BBCB4W ? It doesn't help that I have VERY little knowledge of C or what a "callback function" is so any help would be welcome 
Cheers. Martin.
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Using DLL's
« Reply #1 on: Jul 23rd, 2010, 9:56pm » |
|
on Jul 23rd, 2010, 4:48pm, MartinKing wrote:I'm not sure how to implement "Hik_PlayM4_SetFileRefCallBack" Code:BOOL Hik_PlayM4_SetFileRefCallBack(LONG nPort, void ( _stdcall *pFileRefDone) (DWORD nPort,DWORD nUser),DWORD nUser); |
|
You would need to use the supplied CALLBACK library for that:
http://www.bbcbasic.co.uk/bbcwin/manual/bbcwing.html#callback
The BBC BASIC translation of the above code would be:
Code: SYS FN_syscalln(`Hik_PlayM4_SetFileRefCallBack`), nPort%, \
\ FN_callback(FNFileRefDone(), 2), nUser%
bool% = FN_sysresult And the callback function itself would be coded as:
Code: DEF FNFileRefDone(nPort%, nUser%)
REM Put whatever needs to be done in the callback here
= 0 : REM Type 'void', so return value is unimportant Richard.
|
|
Logged
|
|
|
|
MartinKing
New Member
member is offline


Posts: 2
|
 |
Re: Using DLL's
« Reply #2 on: Jul 23rd, 2010, 10:19pm » |
|
Thanks (again) BTW which is the best forum to post in? This one, the Yahoo one or both? This one has nicer message editing features but being quite new to this I don't know how active both the Forums are?
Cheers. Martin.
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Using DLL's
« Reply #3 on: Jul 24th, 2010, 09:18am » |
|
on Jul 23rd, 2010, 10:19pm, MartinKing wrote:Thanks (again) BTW which is the best forum to post in? |
|
The usual guidance is that if the answer to the question might be of general interest to a large number of users, post it on the Discussion Group. If the query is rather specific, and unlikely to be of general interest, post it here.
If you want to incorporate code listings in your message this is usually the better place; the Yahoo! Group is more likely to muck up the formatting by wrapping lines, adding or removing spaces etc.
The main difference between the forums is that many members of the Yahoo! Group opt to receive messages (or a daily digest) delivered to their inbox, so they get to see them whether they are interested in the subject or not! This board is web-access only, so people only get to read the threads they choose to read.
Richard.
|
|
Logged
|
|
|
|
|