Hi guys,
I took over LeoExtendedNotifications project initially started by NetRipper and it's my first app for WinMobile.
However I got a problem with the RegistrySetString and RegistryGetString methods.
The get method doesn't reads the string value I've created manually but it can't be procedured with strtok.
So I tried writing it with the set method and getting it after that. It works but after I looked into the registry it wrote some weird string in unicode.....
That's what was in the registry:
SEQ = "㔷ㄭ㔲㐭〰㔭ⴰ〵㔭ⴰ〵㔭ⴰ〵㔭"
But it should be:
SEQ = "75-125-400-50-50-50-50-50-50-50"
Did anybody know where's the problem in here?
Here are lines of code to read from registry:
CHAR strSeq[100] = { NULL };
::RegistryGetString(HKEY_LOCAL_MACHINE, appRegPath, TEXT("SEQ"), (LPTSTR) &strSeq, sizeof(strSeq));
Nobody knows why this is happening?
use TCHAR instead of CHAR
RAMMANN said:
use TCHAR instead of CHAR
Click to expand...
Click to collapse
that solved it LOL
ThX man!
Related
I have some problem In the RIL program when I try to get the whole Message...
this is a pointer to Array of Byte..passed to hexdump function..
prmMsg->msgInDeliver.rgbMsg
prmMsg is a RILMESSAGE structure..
If the body of the message is only one char I can read that char...
otherwise no!!
Can anyone Help me??
TCHAR *hexdump(unsigned char *data, int n)
{
static TCHAR buf[1000];
TCHAR *p;
p=buf;
while (n--)
{
p += _sntprintf(p, 4, TEXT("%c"), *data);
}
return buf;
}
Anyone have any Idea???????
Please......
I have the same problem Mister lollone,
I'm not able to read message...
when I shift array ..I read a random part of a memory..
but I cannot read the right sequence of char..
I don't know if anyone have accomplish that..
I don't know why the second and third byte are shifted..
at the first was added 1 bit ....
BYTE rgbMsg[MAXLENGTH_MSG];
why???
anyone know the solution....it's impossible!!!
RILMESSAGE
I have the same problem.......HELP US (qtek8080)
Maybe the problem is caused by Unicode. SMS messages can be sent using Unicode. Because it is double byte, treating it as a standard null terminated string would terminate after the first byte because it would encounter a null byte next.
Solution
Here the solution on how to read SMS:
TCHAR *hexdump(unsigned char *data, int n)
{
static TCHAR buf[1000];
unsigned char use=0;
unsigned char add=0;
unsigned char step=7;
unsigned char lo=0;
char tmp;
unsigned char shdgt=255;
int bpow=0;
unsigned char badd=0;
int pi=0;
int dt=0;
int dgt=0;
while (n--)
{
use = data[dt];
if ( step == 7 ) {
shdgt = shdgt >> 1;
lo = use & shdgt;
tmp= lo;
}
else {
shdgt = shdgt >> 1;
lo = use & shdgt;
tmp = lo << (7 - step);
tmp = tmp | add;
}
// get the digit that have to be used in the next char
dgt = 0;
add = 0;
for (int i=step; i<8; i++) {
bpow = pow(2,i);
badd = pow(2,dgt);
if ( use & bpow)
add = add + badd;
dgt++;
}
buf[pi]=tmp;
pi++;
if ( step == 1 ){
// have an extra char to write
buf[pi]=add;
// reset variables
add = 0;
step= 7;
shdgt=255;
pi++;
}
else
{
step--;
}
dt++;
}
return buf;
}
:wink: :wink:
Grazie mille ora lo proverò
OK i am a begginer at programming in eVC++ i would like to create an application like urs but i dont seem to be able to make it work, i'm a great programmer but eVC++ is bad for me.
Could somebody please post a working source code cos i have serious problems and it is critical for me to get a hold on this kind of source code to help me understand.
Thanks all for ur help !!!!!
Trying to understand RIL and how to pass all the handles and various parameters. In my code i try to initialize RIL and then use the RIL_GetEquipmentInfo function to try and get some results from it. However when i try my application out , i get something like each time i press the command button ....
406
408
40B
411
....
it seems to increment and i thought i was ment to get something like HIMALAYAS back ... Where am i wrong ???
*********************************************
bool CTerminalDlg::RIL_Initialize(DWORD dwIndex)
{
TCHAR szString[256];
CEdit* pEditShow = (CEdit*)GetDlgItem(IDC_EDIT3);
result = ::RIL_Initialize(1, OnResultCallback, OnNotifyCallback, dwNotificationClasses, g_dwParam, &g_hRil);
HRESULT test = RIL_GetEquipmentInfo(g_hRil);
::wsprintf(szString, L" %X", test);
pEditShow->SetWindowText(szString);
return g_hRil != NULL;
}
the result is returned asyncronously via the OnResultCallback function.
alright i get ya ......... so that means the answer i should get ( HTC ) will be passed to a parameter inside the OnResultCallback function ? How would i display it in a message box though ?
thanks for your help i'm struggling here.
1)http://forum.xda-developers.com/viewtopic.php?t=28835
2)there is bad idea to show message box from callback
i think this callback execute in internal RIL thread
get data that you needed from RILEQUIPMENTINFO struct and put to temp buffer
show data from temp buffer in your main thread
for example:
in main thread
1)reset Event
2)call Ril_GetEquipmentInfo
3)wait Event
4)show MessgeBox
in callback
1)store data from RILEQUIPMENTINFO to temp buffer
2)set Event
3)return
Hi all,
I've got a problem that's driving me crazy. I've got a file on the Windows Mobile root which contains more than 26000 chars. In my application I read this file char by char and copy each one to a char (I'll provide you with code later).
OK. After reading the whole file if I check the variable's length (strlen) it returns me the correct one (more than 26000), but if I check the variable's content it shows me only the first 8192 chars and what's more, the function where the code resides must return that variable; but it only returns 8192 chars instead of 26000+.
Does Windows Mobile 5 (Pocket PC) limit char arrays length?
Thanks!!
Here, the code snippet:
Code:
char resp[27000];
memset(resp, 0, 27000);
FILE* cFile;
cFile = fopen("\\test.txt","r");
if(cFile != NULL)
{
int i = 0;
while(feof(cFile)==0)
{
resp[i] = getc(cFile);
i++;
}
}
fclose(cFile);
Can't get rid of this error:
android.database.sqlite.SQLiteException: near "s": syntax error: , while compiling:
Select correct from answers where correct = 'Between the airplane's climb angle and the horizon.'
Obviously, it's finding the single quote in ( airplane's ) and considering that the end of the statement.
I've tried:
correct.replaceAll(" ' ", " ''' "); //replace 1 with 3
correct.replaceAll(" ' ", " '' "); // replace 1 with 2
correct.replaceAll(" ' ", " "); // replace 1 with space
(NOTE: the spaces are NOT in the code, I just did that to make it readable)
I have no idea what's going on, IMO, it should work. Maybe I need to try:
String single = "'"; // single '
String double = "''" // double ''
correct.replaceAll(single, double); // ????
Everything I"ve read about sqlite3 is to replace one with two....
TIA,
Roots
\'
\ is the escape character for most languages
so airplane's would be airplane\'s
Also, are you binding your queries with the "question mark" bind?
I'll try the escape and post back later. There are 1,000 rows in the database and I"m pulling a random subset of that, so it's not that often I get one of those situations.
I'm not sure what you mean by "binding with ?" Isn't that what you use for bind variable unknown at runtime? I know my bind variables and just use it in my dbquery. Please enlighten me...always happy to learn something new
Sample code...answerOne would contain the single quote that's killing me
Code:
Cursor c;
c = myDataBase.rawQuery("Select correct from answers where correct = '" + answerOne + "'", null);
if(c.moveToFirst())
answer = "1";
c.close();
binding with question marks should take care of escaping for you.
Basically the question mark is a place holder for a variable in the query.
What you are doing is manually creating the query string. This is considered bad practice these days especially with regards to security. Mostly because it opens up the DB to a SQL injection attack.
So instead of using the rawQuery just use query and you can put a ? in and android will substitute the value for you, all properly escaped:
Code:
String tableName = "answers";
String selectArgs = "correct=[COLOR="Red"]?[/COLOR]";
// if answerOne is string dont need String.valueOf
String[] selectVals = { String.valueOf ( answerOne ) };
String[] columnsProjection= new String[] {"correct" };
Cursor c = db.query(tableName, columnsProjection, selectArgs,selectVals,null);
So in that code the OS will replace the ? in selectArgs with the values in selectVals
This may seem like more writing at first but once you get in the habit it will be easy, reliable and more secure. It also allows you to bind multiple variables to mutiple question marks. It just binds then in the order it gets them.
so something like this:
Code:
String answerOne= "one";
String selectArgs = "correct=? AND age=? AND smiling=?";
String[] selectVals = { answerOne, "21", "yes" };
Ok, I'll try it. There are about 50 different queries in this program...for some reason I just decided to do a rawQuery on this one. I'll change it to "db.query(table name, new String[] {}....yada, yada).
Because, it just crashed and I decided to come back here and check for a solution.
Thank you very much!!!
Roots
Glad to be of help, just remember to hit the thanks booton ya Rooster
Still getting the error
Example: column is in table as text. Say it's equal to:
The driver's last name
Error comes back as "syntax error near 's' when compiling select correct from answers where correct = 'The driver's last name'
That single quote in driver's is killing my SQL.
Hi!
I am loading a text to TextView from a file on a webpage with my Android app but the problem is that the text is full of ASCII characters, so when the text is loaded to the TextView, I can't see any of these ASCII characters or it shows me a "?" within a black square.
My question is, how can I convert an ASCII character to string?
Thanks for helping.
adamhala007 said:
Hi!
I am loading a text to TextView from a file on a webpage with my Android app but the problem is that the text is full of ASCII characters, so when the text is loaded to the TextView, I can't see any of these ASCII characters or it shows me a "?" within a black square.
My question is, how can I convert an ASCII character to string?
Thanks for helping.
Click to expand...
Click to collapse
Code:
char c = 'e';
String s = String.valueOf(c);
Are you sure that there's no other problem with your code? It doesn't sound like a conversion error.
nikwen said:
Code:
char c = 'e';
String s = String.valueOf(c);
Are you sure that there's no other problem with your code? It doesn't sound like a conversion error.
Click to expand...
Click to collapse
I don't know, but here is my code:
Code:
TextView textMsg;
final String textSource = "PATH/TO/MY/.CRL/FILE";
BufferedReader reader;
URL textUrl;
try {
textUrl = new URL(textSource);
BufferedReader bufferReader = new BufferedReader(
new InputStreamReader(textUrl.openStream()));
String StringBuffer;
String stringText = "";
while ((StringBuffer = bufferReader.readLine()) != null) {
stringText += StringBuffer;
}
bufferReader.close();
textMsg.setText(stringText);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
textMsg.setText(e.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
textMsg.setText(e.toString());
}
I have forgotten to mention that my file where I load the text from has .crl extension. I have tried the code you posted, but the problem still remains. So it shows me still the "?" within the black squares.
adamhala007 said:
I don't know, but here is my code:
Code:
TextView textMsg;
final String textSource = "PATH/TO/MY/.CRL/FILE";
BufferedReader reader;
URL textUrl;
try {
textUrl = new URL(textSource);
BufferedReader bufferReader = new BufferedReader(
new InputStreamReader(textUrl.openStream()));
String StringBuffer;
String stringText = "";
while ((StringBuffer = bufferReader.readLine()) != null) {
stringText += StringBuffer;
}
bufferReader.close();
textMsg.setText(stringText);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
textMsg.setText(e.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
textMsg.setText(e.toString());
}
I have forgotten to mention that my file where I load the text from has .crl extension. I have tried the code you posted, but the problem still remains. So it shows me still the "?" within the black squares.
Click to expand...
Click to collapse
Could you please post an example file?
Can CRL files really be read using a Buffered reader? Aren't the encrypted?
nikwen said:
Could you please post an example file?
Can CRL files really be read using a Buffered reader? Aren't the encrypted?
Click to expand...
Click to collapse
OK. I know why you cannot do it that way:
*.crl files are no text files. When you open them in a browser that supports it, you might see the entries. However, it is no plain text. (You might be able to read some parts, but it is not completely text.)
Proof:
I downloaded a CRL file on my Linux machine.
The way to get its content if it is a textfile is to use the cat command:
Code:
cat <path>
That way I am able to read parts of the file, but most characters aren't real characters. (Things like your ?s.)
So we need another way to do that.
---------- Post added at 09:34 AM ---------- Previous post was at 09:30 AM ----------
You can find classes for reading CRLs in the java.security.cert package: http://developer.android.com/reference/java/security/cert/package-summary.html
EDIT: This seems to be the best tutorial I found so far: http://www.javaworld.com/javaworld/jw-03-2001/jw-0316-howto.html
I found that tutorial with some code snippets: http://jce.iaik.tugraz.at/sic/Support/Technical-Articles/Parsing-Large-CRLs-in-Java
Another tutorial related to CRLs: http://www.nakov.com/blog/2009/12/0...rify-chain-and-verify-clr-with-bouncy-castle/