473,624 Members | 2,565 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems writing SMS's to sim card on pocketpc using simmanager api....

Hey!

At the time being I'm working on a backup solution for a Qtek9090
pocketpc, which should be able to find and backup outlook data to a
server, local files, messages and contact from the sim card (and backup
them to a server as well) all written in C#. So I'm making a wrapper
for the sim manager api. In order to use it's functions in my device
application, I've used platform invoke method, to acces the simmanager
functions from managed c# code. This brings both good and bad - now I
can read messages from the sim card (SimReadMessage function from the
sim manager api, through my wrapper), but when I want to write af
message to the sim card using SimWriteMessage (HSIM hSim, DWORD
dwStorage, LPDWORD lpdwIndex, LPSIMMESSAGE lpSimMessage) or as it looks
in my wrapper (a function just writing an sms to first index on the sim
card):

public void WriteFirstMessa ge(ref SimMessageTag Message)
{
//The arguments: int simHandle, 1 for the storage location, 0 for
the index on the sim card, ref Message is a struct I've made,
corresponding to the struct in the sim manager api representing a
message.
hResult = SimManagerWrapp er.SimWriteMess age(simHandle, 1,
0, ref Message);

if (hResult != 0) // if SimWriteMessage () fails
throw (new Exception("SimM anagerWrapper failed"));
}
I get an error saying that there is invalid parameter.

I think the error occurs because I made some wrong conversions from the
simmanager struct to my c# struct, but I can't see whats wrong.

Here is the c# struct, the conversions I'm most insecure about are the
places where I use the "MarshalAs" function:
public struct SimMessageTag
{
public int cbSize; // Size of the structure in bytes
public int dwParams; //Indicates valid parameter values

[MarshalAs(Unman agedType.ByValT Str, SizeConst = 1500)]
public string lpszAddress; //An array that contains the actual
phone number

public int dwAddressType; //A SIM_ADDRTYPE constant
/*
SIM_ADDRTYPE_UN KNOWN = Unknown.
SIM_ADDRTYPE_IN TERNATIONAL = International number.
SIM_ADDRTYPE_NA TIONAL 0ne National = number.
SIM_ADDRTYPE_NE TWKSPECIFIC Network = specific number.
SIM_ADDRTYPE_SU BSCRIBER Subscriber = number
(protocol-specific).
SIM_ADDRTYPE_AL PHANUM Alphanumeric = address.
SIM_ADDRTYPE_AB BREV Abbreviated = number.
*/

public int dwNumPlan; //A SIM_NUMPLAN constant
/*
SIM_NUMPLAN_UNK NOWN = Unknown.
SIM_NUMPLAN_TEL EPHONE = ISDN/telephone numbering plan
(E.164/E.163).
SIM_NUMPLAN_DAT A = Data numbering plan (X.121).
SIM_NUMPLAN_TEL EX = Telex numbering plan.
SIM_NUMPLAN_NAT IONAL = National numbering plan.
SIM_NUMPLAN_PRI VATE = Private numbering plan.
SIM_NUMPLAN_ERM ES ERMES = numbering plan (ETSI DE/PS 3 01-3).
*/
public DateTime stReceiveTime; //Timestamp for the incoming
message

public int cbHdrLength; //Header length in bytes

[MarshalAs(Unman agedType.ByValA rray, SizeConst = 1500)]
public byte[] rgbHeader; //An array containing the actual
header data

[MarshalAs(Unman agedType.ByValT Str, SizeConst = 10000)]
public string lpszMessage; //An array containing the actual
message data

}

And here is the simmanager struct (from the unmanaged code)
can also be found here:
http://msdn.microsoft.com/library/de...simmessage.asp

typedef struct simmessage_tag {
DWORD cbSize;
DWORD dwParams;
TCHAR lpszAddress[MAX_LENGTH_ADDR ESS];
DWORD dwAddressType;
DWORD dwNumPlan;
SYSTEMTIME stReceiveTime;
DWORD cbHdrLength;
BYTE rgbHeader[MAX_LENGTH_HEAD ER];
TCHAR lpszMessage[MAX_LENGTH_MESS AGE];
} SIMMESSAGE, FAR *LPSIMMESSAGE;

In order to access the unmanaged struct I used platform invoke methods
as follows:

[DllImport("cell core.dll")]
public static extern int SimWriteMessage (int hSim, int
dwStorage, int lpdwIndex, ref SimMessageTag SmsStructType);

So if anybody can help me getting this problem solved It would very
helpful.

If you know that writing messages to the sim card simply isn't doable,
does anyone know if it is possible just to copy all the messages (e.g.
if they lie in af file on the sim or a database), and then restore this
entire file or db instead of taking the sms's one by one?

Sorry for the topic being so long, but I had to led you know what I'm
working on....

Cheers
Bo

Mar 2 '06 #1
0 2252

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
18789
by: Fazer | last post by:
Hello, Can anyone point me to a way on how to send a SMS message using Python? Thanks,
3
1698
by: A-PK | last post by:
May I know if it is possible to write a program using VB.net to send out SMS to handphone ? provided internet connectivity is on
3
1727
by: Mark Morton | last post by:
I'm writing an if statement for a UK credit card form validation script. Users who specify that their card is Switch need to enter either the issue number or the 'valid from' date. I'm trying to write an if statement so that if: 1. The word "Month" is in the validFromMonth field (where they haven't selected a month a the drop-down menu) or the word "Year" is in the validFromYear field (where they haven't selected a year another the...
0
1333
by: joca | last post by:
Hi there, I have scanned the web for information on how to create a component that send and recieve SMS. I have found some information on how to do this if I have a pocket PC, but I want to know if it is possible to use this to make the same connection using a computer and connect a mobile phone to it? http://msdn.microsoft.com/library/default.asp?
11
4789
by: tnhoe | last post by:
Hi, I am looking for above. Any recommendation ? The GSM modem is a data card with phone chip in notebook which can send sms directly without going through other sms gateway URL. I only need to programming api/lib to send sms. Regards Hoe
8
8952
by: Mike9900 | last post by:
We appreciate if you let us know how to send SMS using .NET. -- Mike
6
1874
by: JNeko | last post by:
Hello all, awesome site! I guess I am technically not a beginner in JAVA, but from my code you would not realize it! I don’t expect anyone to help me with this, but I figure I might as well as try and ask. Any help is really appreciated; this should be a piece of cake…driving me crazy. I am writing a simple program (from a book for fun) that creates a deck of cards, shuffles them, gives the user a card, and asks if the next card will be...
4
2916
by: JayaseelanVaiyapuri | last post by:
Hi to all, In PocketPC sdk 5.0, there is a sample application called Callingcard. Which is developed usinf Win32 C++ and the output was dll. Now i would like to develop the same app in C# .net for PocketPC. How to do it?
2
2139
by: anasanjaria | last post by:
I m working on my project, its based on a banking application. What i basically does is send bank account owners an sms after every transaction made to their account. This is to prevent fraud so if, for example, i have a credit card, and someone uses my card ill get an SMS saying where and for how much the card was used after the transaction has been made, that way ill know if any fraud has been commited and i can report it directly to the bank....
0
8249
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8179
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8348
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1493
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.