473,322 Members | 1,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 WriteFirstMessage(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 = SimManagerWrapper.SimWriteMessage(simHandle, 1,
0, ref Message);

if (hResult != 0) // if SimWriteMessage() fails
throw (new Exception("SimManagerWrapper 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(UnmanagedType.ByValTStr, SizeConst = 1500)]
public string lpszAddress; //An array that contains the actual
phone number

public int dwAddressType; //A SIM_ADDRTYPE constant
/*
SIM_ADDRTYPE_UNKNOWN = Unknown.
SIM_ADDRTYPE_INTERNATIONAL = International number.
SIM_ADDRTYPE_NATIONAL 0ne National = number.
SIM_ADDRTYPE_NETWKSPECIFIC Network = specific number.
SIM_ADDRTYPE_SUBSCRIBER Subscriber = number
(protocol-specific).
SIM_ADDRTYPE_ALPHANUM Alphanumeric = address.
SIM_ADDRTYPE_ABBREV Abbreviated = number.
*/

public int dwNumPlan; //A SIM_NUMPLAN constant
/*
SIM_NUMPLAN_UNKNOWN = Unknown.
SIM_NUMPLAN_TELEPHONE = ISDN/telephone numbering plan
(E.164/E.163).
SIM_NUMPLAN_DATA = Data numbering plan (X.121).
SIM_NUMPLAN_TELEX = Telex numbering plan.
SIM_NUMPLAN_NATIONAL = National numbering plan.
SIM_NUMPLAN_PRIVATE = Private numbering plan.
SIM_NUMPLAN_ERMES 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(UnmanagedType.ByValArray, SizeConst = 1500)]
public byte[] rgbHeader; //An array containing the actual
header data

[MarshalAs(UnmanagedType.ByValTStr, 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_ADDRESS];
DWORD dwAddressType;
DWORD dwNumPlan;
SYSTEMTIME stReceiveTime;
DWORD cbHdrLength;
BYTE rgbHeader[MAX_LENGTH_HEADER];
TCHAR lpszMessage[MAX_LENGTH_MESSAGE];
} SIMMESSAGE, FAR *LPSIMMESSAGE;

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

[DllImport("cellcore.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 2231

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

Similar topics

13
by: Fazer | last post by:
Hello, Can anyone point me to a way on how to send a SMS message using Python? Thanks,
3
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
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...
0
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...
11
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...
8
by: Mike9900 | last post by:
We appreciate if you let us know how to send SMS using .NET. -- Mike
6
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...
4
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#...
2
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,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.