I've been looking through the vast amount of info on gaining access to the chipset for sending AT commands. What I'm attempting to do is make this easy within a visual studio .NET project.
My Test device is a HTC touch pro2 running WM6.1
I have translated most of a post from this forum into VB.net. see attached ril.zip for the c code I'm trying to translate. see attached smartdeviceapplication1.zip for my attempt at translation.
My code is attached. I cannot work out the DeviceIoControl function (even after following the MSDN documentation) and the EscapeCommFunction wont work.
I need some help with what I'm doing wrong here. I'm basically trying to translate the c++ code to vb.net code.. (I know, VB.net is for loosers. but with all the people on the internet asking for this, it seems it might be usefull for someone other than just me)
The goal is to make a class to provide direct access to the com ports with .NET.
Let me know if someone has already done this. My searching on the internet only comes up with variants of c code.
Thanks
my code for gretting the DeviceIoControl
<DllImport("coredll.dll", CharSet:=CharSet.Unicode, SetLastError:=True)> _
Public Shared Function DeviceIoControl _
(<[In]()> ByVal hDevice As IntPtr, _
<[In]()> ByVal dwIoControlCode As Int32, _
<[In]()> ByVal lpInputBuffer As IntPtr, _
<[In]()> ByVal nInBufferSize As Integer, _
<Out()> ByVal lpOutBuffer As IntPtr, _
<[In]()> ByVal nOutBufferSize As Integer, _
<Out()> ByRef lpBytesReturned As Integer, _
<[In]()> ByVal lpOverlapped As IntPtr) As Integer
End Function
Ok.. I just realised I needed to initialise the ril and get a new com handle. it then creates com 9 which is the port to use..... It helps when you read the MSDN docs!
Related
Hi there!
Does anyone here uses the GSmart i120 from Gigabyte?
If so, I've got alot of questions about it.
I'm so used to using a phone with a numeric keypad, Like Nokia to compose SMS using one hand.
Now that I have this GSmart i120, I thought it works the same as a Nokia when typing SMS using the keypad..But I was wrong.
It has this input thing called "Smart Keypad" which is not so Smart as I find it really dumb and stupid.
It lets you type in the text or characters using the keypad alright, but it has this lag or wait time that is really slow that you have to wait maybe 1.5 seconds just to be able to type-in the next character. and if you press another key, then it will type-in the letter or character of that key.
I've found this CAB file for the Phone Pad from another PPC-Phone device (i forgot where it was extracted from) and it sort of works like a Nokia keypad when typing SMS. but it uses the touch-screen LCD. what I'd like to do is maybe modify that CAB file so that it will instead MAP the numeric keypad of my device.
So, my question is can anyone help me in finding a solution to this?
I Have here the code to MAP the hardware keypad, but i don't know how to do it and integrate it with the Phone Pad.
Paste the following code into a module, and call in in the form_load as follows:-
Dim messageWindow As Hwbuttons.hwMessageWindow
Me.messageWindow = New Hwbuttons.hwMessageWindow(Me)
RegisterHKeys.RegisterRecordKey(Me.messageWindow.H wnd)
Imports Microsoft.WindowsCE.Forms
Imports System.Runtime.InteropServices
Public Enum KeyModifiers As Integer
None = 0
Alt = 1
Control = 2
Shift = 4
Windows = 8
Modkeyup = &H1000
End Enum
Public Enum KeysHardware As Integer
Hardware1 = 193
Hardware2 = 194
Hardware3 = 195
Hardware4 = 196
Hardware5 = 202
End Enum
Public Module RegisterHKeys
<DllImport("coredll.dll", Entrypoint:="RegisterHotKey", setLastError:=True)> _
Public Function RegisterHotKey( _
ByVal hWnd As IntPtr, _
ByVal id As Integer, _
ByVal Modifiers As KeyModifiers, _
ByVal key As Integer) As Boolean
End Function
<DllImport("coredll.dll")> _
Private Function UnregisterFunc1( _
ByVal modifiers As KeyModifiers, _
ByVal keyID As Integer) As Boolean
End Function
Public Sub RegisterRecordKey(ByVal hWnd As IntPtr)
UnregisterFunc1(KeyModifiers.Windows, CType(KeysHardware.Hardware1, Integer))
RegisterHotKey(hWnd, CType(KeysHardware.Hardware1, Integer), KeyModifiers.Windows, CType(KeysHardware.Hardware1, Integer))
UnregisterFunc1(KeyModifiers.Windows, CType(KeysHardware.Hardware2, Integer))
RegisterHotKey(hWnd, CType(KeysHardware.Hardware2, Integer), KeyModifiers.Windows, CType(KeysHardware.Hardware2, Integer))
UnregisterFunc1(KeyModifiers.Windows, CType(KeysHardware.Hardware3, Integer))
RegisterHotKey(hWnd, CType(KeysHardware.Hardware3, Integer), KeyModifiers.Windows, CType(KeysHardware.Hardware3, Integer))
UnregisterFunc1(KeyModifiers.Windows, CType(KeysHardware.Hardware4, Integer))
RegisterHotKey(hWnd, CType(KeysHardware.Hardware4, Integer), KeyModifiers.Windows, CType(KeysHardware.Hardware4, Integer))
UnregisterFunc1(KeyModifiers.Windows, CType(KeysHardware.Hardware5, Integer))
RegisterHotKey(hWnd, CType(KeysHardware.Hardware5, Integer), KeyModifiers.Windows, CType(KeysHardware.Hardware5, Integer))
End Sub
Public Class Hwbuttons
Inherits System.Windows.Forms.Form
Public Shared messageWindow As hwMessageWindow
Public Class hwMessageWindow
Inherits messageWindow
Public Const WM_HOTKEY = &H312
Dim example As frmComms
Public Sub New(ByVal example As frmComms)
Me.example = example
End Sub
Protected Overrides Sub WndProc(ByRef msg As Message)
Select Case msg.Msg
Case WM_HOTKEY
'ButtonPressed(msg.WParam.ToInt32())
Return
End Select
MyBase.WndProc(msg)
End Sub
Public Sub ButtonPressed(ByVal button As Integer)
Select Case button
Case KeysHardware.Hardware1
MessageBox.Show("Button 1 pressed!")
Exit Sub
Case KeysHardware.Hardware2
MessageBox.Show("Button 2 pressed!")
Exit Sub
Case KeysHardware.Hardware3
MessageBox.Show("Button 3 pressed!")
Exit Sub
Case KeysHardware.Hardware4
MessageBox.Show("Button 4 pressed!")
Exit Sub
Case KeysHardware.Hardware5
MessageBox.Show("Button 5 pressed!")
Exit Sub
End Select
End Sub
End Class
End Class
End Module
Also, the phone has a TV-recording function, but it records only in 3GP instead of the more decent Mpeg format. Can anyone also help me out with this? I'd sure appreciate it! Thanks.
And also, I think the device doesn't support or doesn't have the AVRCP Bluetooth profile, is there a Hack or a CAB file that I can download so I can have AVRCP support on the GSmart i120?
hello !!
i also use i120 ! can you find a solution for it???
Hello friends,
First off, please check below code. Well, I am developing printing functionality from the windows mobile device using vc++. (I am novice to the vc++ ). For printing, we are using third party DLLs. Below are important snippet required to explain the complete picture. Currently, the problem I am more concerning is printing multiple pages. For this, we have API and everything. While printing using “mpPreviewDialog” API (provided by third party in form of DLL) and when it recognize more than one pages required, it raises/passes “MP_EVENT_REQ_NEW_PAGE” message from printing library, ie mpPreviewDialog itself, to the handle hWnd of “mpPreviewDialog(hWnd,__)”. Now, to handle this message, we have put all logic portion in one class which is inherited from CWnd so that we can override “DefWindowProc” function to achieve our goal. But while I run the application and command print for multiple page, it only prints the first page perfectly and then just get hanged. Thus, it fails to handle the “MP_EVENT_REQ_NEW_PAGE” message of “DefWindowProc” function. What all I need is to handle this message and execute the case MP_EVENT_REQ_NEW_PAGE: while printing and multiple page required. Because in this case it issues the message but appropriate case never get executed. I hope you got my point. Please let me know how to solve this. Am I missing something? Thank you very much for your time in advance.
class CFxPrinterWnd : public CWnd
{
DECLARE_DYNCREATE(CFxPrinterWnd)
public:
CFxPrinterWnd(); // protected constructor used by dynamic creation
virtual ~CFxPrinterWnd();
public:
#ifdef _DEBUG
virtual void AssertValid() const;
#ifndef _WIN32_WCE
virtual void Dump(CDumpContext& dc) const;
#endif
#endif
protected:
DECLARE_MESSAGE_MAP()
public:
int PrintReport(HWND hwnd, int flg);
protected:
virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
};
Int CFxPrinterWnd:rintReport (HWND hWnd, int flg)
{
_______
This contains “mpPreviewDialog” API call which starts printing and issue “MP_EVENT_REQ_NEW_PAGE” message if more than one page required.
}
LRESULT CFxPrinterWnd:efWindowProc(___,___,___)
{
Switch (message)
{
___
Case MP_EVENT_REQ_NEW_PAGE: //This debug point never get focused while printing and new page required.
___This point is never get executed
___
}
}
Button1 Click Event
{
hWnd = ::FindWindow(NULL, _T(“del”));
CFxPrinterWnd wnd;
Wnd.Create(_______________________);
Ret = wnd.PrintReport(hWnd, 0);
___
___
mpPreviewDialog (hWnd____); //This is the printing API where MP_EVENT_REQ_NEW_PAGE message get raised while printing if new page
//required.
wnd.DestroyWindow();
}
---
Kind Regards,
Sachin Patel
I'm trying to hide the incoming call window, but it's not working.
I declare the functions
Public Declare Function ShowWindow Lib "Coredll" (ByVal hWnd As IntPtr, ByVal iVisible As Integer) As Boolean
Public Declare Function FindWindow Lib "Coredll" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Then call
ShowWindow(FindWindow("", "Phone - Incoming"), 0)
But the window is still there. And yes the window title is correct. I've been trying to debug for over an hour. I don't get any errors it just doesn't work. Any help is greatly appreciated.
Hi,
I try to install a Keyboard Hook to get volume key presses in .NET 3.5.
But it fails. Does someone know how to do it?
This is my VB .NET code:
Code:
Imports System.Runtime.InteropServices
Public Delegate Function HookCallback(ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As intptr) As Integer
Public Class Form1
<MarshalAs(UnmanagedType.FunctionPtr)> _
Private callbackKeyboard As HookCallback
Private Shared hHookKeyboard As Integer = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If hHookKeyboard.Equals(0) Then
callbackKeyboard = New HookCallback(AddressOf KeyboardHookProc)
hHookKeyboard = WinApi.SetWindowsHookEx(WinApi.WH_KEYBOARD_LL, callbackKeyboard, WinApi.GetModuleHandle(Nothing), 0)
If hHookKeyboard.Equals(0) Then
MessageBox.Show("Keyboard Hook Failed:" & vbCrLf & hHookKeyboard.ToString() & vbCrLf & Marshal.GetLastWin32Error(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
End If
End If
End Sub
End Class
'API Functions
Public Class WinApi
Public Const WH_KEYBOARD_LL As Integer = 13
Public Structure KBDLLHOOKSTRUCT
Public vkCode As Integer
Public scanCode As Integer
Public flags As Integer
Public time As Integer
Public dwExtraInfo As Integer
End Structure
<DllImport("coredll.dll")> _
Public Shared Function SetWindowsHookEx( _
ByVal idHook As Integer, ByVal HookProc As HookCallback, _
ByVal hInstance As IntPtr, ByVal wParam As Integer) As Integer
End Function
<DllImport("coredll.dll")> _
Public Shared Function GetModuleHandle(ByVal mod2 As String) As IntPtr
End Function
<DllImport("coredll.dll")> _
Public Shared Function CallNextHookEx( _
ByVal idHook As Integer, ByVal nCode As Integer, _
ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Integer
End Function
End Class
glad to claim not vb knowlege at all but I can advice you to search
for c# solutions as everything which can be don in c# can be don as
far as I know in vb.net even if the syntes is horrid
thing is most people who you want to get advice from would never
use vb but if you read their stuff you can with a bit of skill convert it
from c# to vb.net even if it makes baby jesus cry
Well, this Code is inspired by C# code from here.
I know that most .NET developers use C# and not VB so I searched for C# code too. I've already used keyboard hooks in desktop apps but this does not work for .NET CF.
Very strange, I tried the same code in C# and it worked!
So I'll write my app in C#
Whatever language you have written the code in should not make any difference. Take the C# generated .EXE file or .DLL that works, and load it into RED GATE's .NET Reflector.
http://www.red-gate.com/products/reflector/
A freeware download, just agree to the disclaimer etc.
Load your program in it and navigate down until the code appears in the main window. It will show you the C# code that was used to create it. It won't know the variable names but it will replace them with int1,int2,string1,float1 etc.
Here's the clever bit, use the drop down box to switch the language to VB, and it will display the VB code to do the same job. You should be able to spot the difference in the code compared to your own VB original.
Hallo to XDA DEVELOPERS,
Please very much, I want ask for trouble, which I cant solve for many days.
I read many informations about receiving SMS, I tryed many examples of code and I build many codes which are from my head, but it not functioned.
Please, I have very big trouble. Many days I try develope application for receiving SMS, but I cant this.
I can send sms and use mobile and outlook functions, but I CANT RECEIVE SMS.
This is one of my code:
Imports Microsoft.WindowsMobile.PocketOutlook.MessageInterception
Imports Microsoft.WindowsMobile.Telephony
Imports Microsoft.WindowsMobile
Imports Microsoft.WindowsMobile.PocketOutlook
Imports System.Messaging
Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports Microsoft.WindowsMobile.Status
PublicClass Form1
Private _smsInterceptor As MessageInterceptor
PrivateSub Form1_Load(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesMyBase.Load
If MessageInterceptor.IsApplicationLauncherEnabled(_appId) Then
_smsInterceptor = New MessageInterceptor(_appId)
Else
_smsInterceptor = New MessageInterceptor(InterceptionAction.Notify)
_smsInterceptor.MessageCondition = New MessageCondition(MessageProperty.Body, _
MessagePropertyComparisonType.StartsWith, "www")
EndIf
AddHandler _smsInterceptor.MessageReceived, New MessageInterceptorEventHandler(AddressOf SmsInterceptor_MessageReceived)
Display("Event Wired")
EndSub
Sub Display(ByVal text AsString)
TextBox1.Text &= text & vbCrLf
EndSub
PrivateSub SmsInterceptor_MessageReceived(ByVal sender AsObject, ByVal e As MessageInterceptorEventArgs)
Display("Received")
Dim theMessage As SmsMessage = TryCast(e.Message, SmsMessage)
IfNot theMessage IsNothingThen
Display("Msg: " & theMessage.From.Address & " - " & theMessage.Body)
EndIf
EndSub
Const _appId AsString = "sms"
PrivateSub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If MessageInterceptor.IsApplicationLauncherEnabled(_appId) Then
_smsInterceptor = New MessageInterceptor(_appId)
Else
_smsInterceptor = New MessageInterceptor(InterceptionAction.Notify)
_smsInterceptor.MessageCondition = New MessageCondition(MessageProperty.Body, _
MessagePropertyComparisonType.StartsWith, "www")
EndIf
AddHandler _smsInterceptor.MessageReceived, New MessageInterceptorEventHandler(AddressOf SmsInterceptor_MessageReceived)
EndSub
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
_smsInterceptor.EnableApplicationLauncher(_appId)
EndSub
PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
_smsInterceptor.DisableApplicationLauncher()
EndSub
EndClass
' ------------------------------------------------------------------------
But trouble is, that this:
AddHandler _smsInterceptor.MessageReceived, New MessageInterceptorEventHandler(AddressOf SmsInterceptor_MessageReceived)
I thing that this not see incomming message....and I dont know why.....???
When I see registers then in folder INBOX/RULES I see Rules which set this code, but when comes SMS then nothing is happen...
Idont know , what can I do, please very much, very,very, I need help, please for advice.
I have windows mobile 6.3
HTC mobile phone
All is functioned, but receiving sms I cant solve,
please very much for advice
Thank you and nice day