-1

Thanks to Josef who put me onto the right track for coding Windows Mobile 6.5 phone support.

I have found some more tricks which I would like to share. Yes, I know it is old technology, but there are many devices being sold that still run mobile 6.5. So: How can I program the speakerphone on a pocketpc running Windows Mobile 6.5 in .NET Compact Framework 3.5 in VB.NET?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
John Agar
  • 29
  • 3

1 Answers1

0

This is very simple once you know how. You call the DLL file ossvcs, but this DLL file exports functions by ordinal numbers, not by names.

See http://msdn.developer-works.com/article/12376405/Reject+Call for more details. The code follows:

<DllImport("ossvcs.dll", EntryPoint:="#218")> _
Private Shared Sub setSpeaker(ByVal sValue As Integer)
End Sub

' Call setSpeaker(1) to turn on and setSpeaker(0) to turn off.
' If you set the speaker on when you create the line than it will always turn the speaker on for every call made
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
John Agar
  • 29
  • 3
  • Please use these undocumented functions with caution. They may influence other API calls. If possible, free ossvcs.dll immediately after calling. I saw an issue with DirectShow as ossvcs.dll was loaded and SetSpeakerMode was used. – josef Jul 06 '16 at 03:48
  • Thank you. How do I free a loaded dll? – John Agar Jul 07 '16 at 06:15
  • That can be only done using LoadLibary, GetProcAddress and FreeLib. See the invokes for that or my SetSpeakerMode2 which uses a C++ DLL which wraps that and can be used by .NET: https://github.com/hjgode/SetSpeakerMode – josef Jul 08 '16 at 11:15
  • I have done more research and agree that freelib must be called through a wrap ala your sample. But then I end up with another dll in memory that is no longer required. The OS will only free a dll when its calling program is terminated. As I have other dll's that are only used once, e.g. I have a dll to kill the process "cprog.exe", I am considering a separate program to do this work and then shelling out to this program. When the shelled program terminates the dll's it has used will be unloaded by the OS. The overhead is only incurred at startup. Will this work? – John Agar Jul 13 '16 at 06:30
  • "The OS will only free a dll when its calling program is terminated" - NO, you can load the DLL dynamically and then use freeLib to detach the DLL from the process. – josef Jul 14 '16 at 14:14
  • Thank you. Much appreciated – John Agar Jul 16 '16 at 05:24
  • Is the link broken? – Peter Mortensen Oct 21 '17 at 11:53