hi every body
how can i use a dll inside the gadget code and if it is required to regsiter the dll
please any one know answer reply
thanks
Fathi S. Elashery
hi every body
how can i use a dll inside the gadget code and if it is required to regsiter the dll
please any one know answer reply
thanks
Fathi S. Elashery
Dll inside gadget
FarReachJason
Yes, you just need to register the DLL and then use the functions I've exposed to call DirectSound. If you download Asteroids you'll have all the code you need. Feel free to use the DLL.
Because I wrote the DLL in VB6, you'll need to register the DirectX VB library that exposes DX to VB (it doesn't come with Vista as it only includes DX10). When I get time, I'll recode it in C so it works natively with DX10 without this requirement.
You need to first initialise DirectSound to the Sidebar window via:
//get the Sidebar window handle and initialise DirectSound
var whandle = DSXLib.GetWindowHandle("SideBar_AppBarWindow");
var sound = DSXLib.Initialize(whandle) false : true;
then you need to check it registered and load the sounds:
var sounds = new Array();
if (!sound)
System.Debug.outputString("DX8VB.DLL not registered");
else
{
//load the sounds in to DirectSound buffers
sounds[0] = DSXLib.LoadSound(gadgetPath + "\\sounds\\explode1.wav", false, 1, 11025, 8);
}
then set the volumes:
for(i=0; i<1; i++)
DSXLib.SetVolume(sounds
and finally Play/Stop sounds
DSXLib.PlaySound(sounds[0]);
DSXLib.StopSound(sounds[0]);
The DirectSound functions exposed are:
Initialize(ByRef handle As Long) As Integer
Initializes DirectSound to windows <handle>
LoadSound(ByVal SourceName As String, IsLoop As Boolean, NumChannels As Long, SamplesPerSecond As Long, BitsPerSample As Long) As Integer
Load the sound file "SourceName".
IsLoop is true if the sound is to be looped
NumChannels is the number of sound channels (ie 1 mono, 2 stereo)
SamplesPerSecond is the Hz
BitsPerSample (8, 16, 24 etc)
Outputs the Index the Sound was loaded into
PlaySound(Index As Integer)
Play sound loaded into Index <Index>
StopSound(Index As Integer)
Stop sound loaded into Index <Index>
SetVolume(Index As Integer, Vol As Long)
Set volume of sound loaded into Index <Index>
And one user32.dll function:
GetWindowHandle(s As String) As Long
Returns the window handle of the first window to match the name <s>
One thing I did miss out was a Terminate function to release all the sounds. I didn't code it because at the time, there was no way to capture the Gadget closing. I've since found out (from Bruce above) that MS fixed that so, I'll add this in a later version.
Muhammad Adel
Couple of questions I have:
Is dsxlib.dll, own library (or based on the name is it direct sound library)
Lets say I wanted to use a different lib such as DirectSound for playing audio files, would all I have to do is register the dll and make the appropriate calls to it such as in the direct x sdk
Any clarification on this would help (slowly my mind is filling with the amount of possibilities just based on using dll's for external functions that a gadget natively can't handle).
WinFormsUser13232
DKB
Earlier beta versions had that problem, but the final bits should consistently call body.onunload when the gadget or sidebar is shut down. Let us know if you see this not working.
Vramin
Just checked it, "body.onunload" now works in RTM. So, the matching code for the example above is:
gadget.html
<BODY onload="startUpGadget();" onunload="UnregisterDSXLib();">
gadget.js
function UnregisterDSXLib() {
try{
oShell.RegDelete("HKCU\\Software\\Classes\\CLSID\\{0CEB6AEC-51FB-475F-8472-68869273C4EA}\\Implemented Categories\\{40FC6ED5-2438-11CF-A3DB-080036F12502}\\");
oShell.RegDelete("HKCU\\Software\\Classes\\CLSID\\{0CEB6AEC-51FB-475F-8472-68869273C4EA}\\Implemented Categories\\");
oShell.RegDelete("HKCU\\Software\\Classes\\CLSID\\{0CEB6AEC-51FB-475F-8472-68869273C4EA}\\InprocServer32\\");
oShell.RegDelete("HKCU\\Software\\Classes\\CLSID\\{0CEB6AEC-51FB-475F-8472-68869273C4EA}\\ProgID\\");
oShell.RegDelete("HKCU\\Software\\Classes\\CLSID\\{0CEB6AEC-51FB-475F-8472-68869273C4EA}\\TypeLib\\");
oShell.RegDelete("HKCU\\Software\\Classes\\CLSID\\{0CEB6AEC-51FB-475F-8472-68869273C4EA}\\VERSION\\");
oShell.RegDelete("HKCU\\Software\\Classes\\CLSID\\{0CEB6AEC-51FB-475F-8472-68869273C4EA}\\");
oShell.RegDelete("HKCU\\Software\\Classes\\DSXLib.DSX\\Clsid\\");
oShell.RegDelete("HKCU\\Software\\Classes\\DSXLib.DSX\\");
oShell.RegDelete("HKCU\\Software\\Classes\\TypeLib\\{B45FD794-9BE7-4B5D-BDD5-1FAD8A4D3855}\\2.0\\0\\win32\\");
oShell.RegDelete("HKCU\\Software\\Classes\\TypeLib\\{B45FD794-9BE7-4B5D-BDD5-1FAD8A4D3855}\\2.0\\0\\");
oShell.RegDelete("HKCU\\Software\\Classes\\TypeLib\\{B45FD794-9BE7-4B5D-BDD5-1FAD8A4D3855}\\2.0\\FLAGS\\");
oShell.RegDelete("HKCU\\Software\\Classes\\TypeLib\\{B45FD794-9BE7-4B5D-BDD5-1FAD8A4D3855}\\2.0\\HELPDIR\\");
oShell.RegDelete("HKCU\\Software\\Classes\\TypeLib\\{B45FD794-9BE7-4B5D-BDD5-1FAD8A4D3855}\\2.0\\");
oShell.RegDelete("HKCU\\Software\\Classes\\TypeLib\\{B45FD794-9BE7-4B5D-BDD5-1FAD8A4D3855}\\");
} catch(err) {System.Debug.outputString("UnregisterDSXLib: "+err)}
}
tokie
If you have a look at either my WMP or Asteroids Gadgets, you'll see how this is done. Here's the core of it:
var gadgetPath = System.Gadget.path;
var oShell = new ActiveXObject("WScript.Shell");
RegisterDSXLib();
var DSXLib = new ActiveXObject("DSXLib.DSX");
...
function RegisterDSXLib() {
try{
oShell.RegWrite("HKCU\\Software\\Classes\\CLSID\\{0CEB6AEC-51FB-475F-8472-68869273C4EA}\\","DSXLib.DSX", "REG_SZ");
oShell.RegWrite("HKCU\\Software\\Classes\\CLSID\\{0CEB6AEC-51FB-475F-8472-68869273C4EA}\\Implemented Categories\\{40FC6ED5-2438-11CF-A3DB-080036F12502}\\", "", "REG_SZ");
oShell.RegWrite("HKCU\\Software\\Classes\\CLSID\\{0CEB6AEC-51FB-475F-8472-68869273C4EA}\\InprocServer32\\", gadgetPath + "\\DSXLib.dll", "REG_SZ");
oShell.RegWrite("HKCU\\Software\\Classes\\CLSID\\{0CEB6AEC-51FB-475F-8472-68869273C4EA}\\InprocServer32\\ThreadingModel", "Apartment", "REG_SZ");
oShell.RegWrite("HKCU\\Software\\Classes\\CLSID\\{0CEB6AEC-51FB-475F-8472-68869273C4EA}\\ProgID\\", "DSXLib.DSX", "REG_SZ");
oShell.RegWrite("HKCU\\Software\\Classes\\CLSID\\{0CEB6AEC-51FB-475F-8472-68869273C4EA}\\TypeLib\\", "{B45FD794-9BE7-4B5D-BDD5-1FAD8A4D3855}", "REG_SZ");
oShell.RegWrite("HKCU\\Software\\Classes\\CLSID\\{0CEB6AEC-51FB-475F-8472-68869273C4EA}\\VERSION\\", "2.0", "REG_SZ");
oShell.RegWrite("HKCU\\Software\\Classes\\DSXLib.DSX\\", "DSXLib.DSX", "REG_SZ");
oShell.RegWrite("HKCU\\Software\\Classes\\DSXLib.DSX\\Clsid\\", "{0CEB6AEC-51FB-475F-8472-68869273C4EA}", "REG_SZ");
oShell.RegWrite("HKCU\\Software\\Classes\\TypeLib\\{B45FD794-9BE7-4B5D-BDD5-1FAD8A4D3855}\\2.0\\", "DSXLib", "REG_SZ");
oShell.RegWrite("HKCU\\Software\\Classes\\TypeLib\\{B45FD794-9BE7-4B5D-BDD5-1FAD8A4D3855}\\2.0\\0\\win32\\", gadgetPath + "\\DSXLib.dll", "REG_SZ");
oShell.RegWrite("HKCU\\Software\\Classes\\TypeLib\\{B45FD794-9BE7-4B5D-BDD5-1FAD8A4D3855}\\2.0\\FLAGS\\", "0", "REG_SZ");
oShell.RegWrite("HKCU\\Software\\Classes\\TypeLib\\{B45FD794-9BE7-4B5D-BDD5-1FAD8A4D3855}\\2.0\\HELPDIR\\", gadgetPath, "REG_SZ");
} catch(err) {System.Debug.outputString("RegisterDSXLib: "+err)}
}
Wicket
Is it possible to create an ActiveX control with C# instead of VB6
Thanks in advance