Hi,
I need to use the C++ version of this. The code should gather information and show this in a notification.
The notification works but I want to receive the choice the user made in the html form.
I know I need to use the hwsink, a message map, and some events but cannot find info (book, example, etc.) how.
Could some one finish this code so I can test what has been chosen. If NOT, please give me an C++ example from which I can learn/copy. I have been searching on google for days now
Thx, for your help
BTW:
I started with this http://www.krvarma.com/?p=146 downloaded code but was a bit to complicated. In it is all I need but i would like it to be in 1 cpp file.
I'm offering 2 beers if you have the solution
Code:
#include "stdafx.h"
#include <stdlib.h>
#include "resource.h"
// {4E8A9888-D15C-4395-9C9A-B4B572F20081}
static const GUID NOTIFICATION_GUID =
{ 0x4e8a9888, 0xd15c, 0x4395, { 0x9c, 0x9a, 0xb4, 0xb5, 0x72, 0xf2, 0x0, 0x81 } };
int _tmain(int argc, _TCHAR* argv[])
{
SHNOTIFICATIONDATA stcNtData = {0};
stcNtData.cbStruct = sizeof(stcNtData);
stcNtData.dwID = 1;
stcNtData.npPriority = SHNP_INFORM;
stcNtData.csDuration = 15;
// stcNtData.hicon = LoadIcon((HINSTANCE)GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON2));
stcNtData.clsid = NOTIFICATION_GUID;
//What todo here... stcNtData.hwndSink = hWnd;
stcNtData.grfFlags = SHNF_SILENT | SHNF_TITLETIME | SHNF_CRITICAL | SHNF_FORCEMESSAGE;
stcNtData.pszTitle = L"ReRemind";
//stcNtData.pszHTML = TEXT("<html><body>This is a sample application to show the SHNotificationAdd API")
// TEXT("<p><b>This line should be bold</b>.<br><i>This one should be italics.</i><br>")
// TEXT("This is a line with a <a href='cmd:10000'>link</a></p>")
// TEXT("<p>This is a line with <input type='button' name='cmd:10001' value='Click'></p><br><br><br><br>");
stcNtData.pszHTML = TEXT("<form method='get' action='TestBubble://Test'>")
TEXT("<table width=100% cellspacing=0 cellpadding=0>")
TEXT("<tr><td colspan=2>")
TEXT("<b>Choose a fruit:</b><p>")
TEXT("<input type='radio' value='0' id='Apples' checked name='Fruit'><label for='Apples'>Apples</label><br>")
TEXT("<input type='radio' value='1' id='Oranges' name='Fruit'><label for='Oranges'>Oranges</label></p></td><td>")
TEXT("<input type='submit' value='Submit' name='Submit'>")
TEXT("</td></tr><tr><td width=42>")
TEXT("<a href='cmd:12288'>Settings</a></td></tr></table></form><br><br><br><br>");
SHNotificationAdd(&stcNtData);
Sleep(15000);
SHNotificationRemove(&NOTIFICATION_GUID, 1);
return 0;
}
I'm offering beers now. No need to finish it, just give me some hints
Hi,
as I understand your article (http://www.krvarma.com/?p=146)
you need to create window, then assign it's HWND
to SHNOTIFICATIONDATA member HWND hwndSink;
then "The system will send WM_COMMAND with wParam set to 1000 to the hwndSink window." so - you need to handle WM_COMMAND in your window and check wParam - if it is equal to your parameter, then this message means "system sends you user choice from your html".
serfer222 said:
Hi,
as I understand your article (http://www.krvarma.com/?p=146)
you need to create window, then assign it's HWND
to SHNOTIFICATIONDATA member HWND hwndSink;
then "The system will send WM_COMMAND with wParam set to 1000 to the hwndSink window." so - you need to handle WM_COMMAND in your window and check wParam - if it is equal to your parameter, then this message means "system sends you user choice from your html".
Click to expand...
Click to collapse
Exactly as i understand it.
So I tried copying code from that article into my code but got stuck with really not understandable compiler errors. I think I need to find a good book explaining this message map.
The first thing I do not understand is that I only want to show the notification bubble (is working). If I create a windows handle (how?) will this overwrite the current screen (this is something I do not want).
window can be invisible.
I'm Win32 programmer, and I don't know exactly about WinCE.
If you are using VisualC++, I think you should use MFC, it's very easy to create window and then create message handler for this window.
search google for some
"WinCE c++ tutorial" and you will find how to create window and setup message loop. (add "Hello world" phrase to your search - this is usually used as very first example)
for example: http://www.codeproject.com/KB/mobile/ltwtdlg.aspx
serfer222 said:
window can be invisible.
I'm Win32 programmer, and I don't know exactly about WinCE.
If you are using VisualC++, I think you should use MFC, it's very easy to create window and then create message handler for this window.
search google for some
"WinCE c++ tutorial" and you will find how to create window and setup message loop. (add "Hello world" phrase to your search - this is usually used as very first example)
for example: http://www.codeproject.com/KB/mobile/ltwtdlg.aspx
Click to expand...
Click to collapse
Can you switch between MFC, ATL, etc. ? I know they are some kind of libraries but thought "don't look at it, there too much to learn/understand anyway ".
I've search but somehow you think there is the solution and then you learn the hard way, it's very old code. Will search further offcourse and I am reading a chapter on classes and if I can find; messages.
it's already very easy to handle messages without any MFC overload. Just check the uMsg parameter in your DefWindowProc. If you create a new Win32 project in Visual C++ wizard then you see what it's looking like. This is mandatory knowledge. Usually first thing you learn after Hello World. If you didn't know about message processing in Windows/Wince then it's the same like sitting in a car and don't know how to turn the keys.
Do you know how to open dsm file in textbox???
RAMMANN said:
it's already very easy to handle messages without any MFC overload. Just check the uMsg parameter in your DefWindowProc. If you create a new Win32 project in Visual C++ wizard then you see what it's looking like. This is mandatory knowledge. Usually first thing you learn after Hello World. If you didn't know about message processing in Windows/Wince then it's the same like sitting in a car and don't know how to turn the keys.
Click to expand...
Click to collapse
Thats how I feel exactly. It's strange. I read quickly thru 3 books about C++ and no mention of these messages. C#/Basic are easier to understand because of all the examples.
Found these:
- http://www.youtube.com/watch?v=kWVGqV2Yklw
- http://www.youtube.com/watch?v=cbe6yxBHEiU
The video does explain that the linked example doesn't look so different. What a lot of source code Ms creates for you..
If created a WIN32 smart device project and DefWindowsProc is only called when to pass the message to other programs. I need the windows handle for the notification and NOT display the window.
But again it's a bit to much for me at this moment. I haven't got a solution yet..Could somebody help me with not displaying this window. I would still like to use the windows handle to make sure I get the callbakcs to the WM_COMMAND.
Yes - I think you only need at end of WinMain before SHNotificationRemove
to add:
Code:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hacc, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Then a new function:
Code:
/* Redefine generic HANDLE_WM_ACTIVATE macro for Pocket PC */
#undef HANDLE_WM_ACTIVATE
#define HANDLE_WM_ACTIVATE(hwnd,wParam,lParam,fn) \
(SHHandleWMActivate((hwnd), (wParam), (lParam), &g_sai, 0), /*return*/ 0L)
/* Redefine generic HANDLE_WM_SETTINGCHANGE macro for Pocket PC */
#undef HANDLE_WM_SETTINGCHANGE
#define HANDLE_WM_SETTINGCHANGE(hwnd,wParam,lParam,fn) \
(SHHandleWMSettingChange((hwnd), (wParam), (lParam), &g_sai), /*return*/ 0L)
static LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
HANDLE_MSG(hwnd, WM_CREATE, Main_OnCreate);
HANDLE_MSG(hwnd, WM_ACTIVATE, /* SHHandleWMActivate()*/ 0);
HANDLE_MSG(hwnd, WM_SETTINGCHANGE, /* SHHandleWMSettingChange() */ 0);
HANDLE_MSG(hwnd, WM_PAINT, Main_OnPaint);
HANDLE_MSG(hwnd, WM_COMMAND, Main_OnCommand);
HANDLE_MSG(hwnd, WM_DESTROY, Main_OnDestroy);
[B]// Remark: Here you can add more messages - also for what user has chosen.[/B]
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
}
and then the message handlers like this:
Code:
static BOOL Main_OnCreate(HWND hwnd, CREATESTRUCT *pcs)
{
SHMENUBARINFO mbi;
memset(&mbi, 0, sizeof(mbi));
mbi.cbSize = sizeof(mbi);
mbi.hwndParent = hwnd;
mbi.nToolBarId = IDR_MNU_MAIN;
mbi.hInstRes = g_hInstance;
if (!SHCreateMenuBar(&mbi)) /* create the menu bar */
return FALSE;
g_hwndMB = mbi.hwndMB;
return TRUE;
}
But your Compiler should already make such a project by default and you can simple add the code fom _tmain to WinMain, which you've posted above.
Greetz
Micha
Thank you, yesterday I debugged and and debugged trying to understand how this works but the debugger doesn't stop always in all source code.
If f.i. you click on the screen I expected this to be an event, but the debugger didn't stop at all. Is there a command to always stop when a line of code is processed? Now it only stops when I have set a break point. I want to see every line processed...
I will try to implement your suggestions. For a newby it still looks difficult I hope someday I will look back to this and say "wow, that was so easy".
ajhvdb said:
Thank you, yesterday I debugged and and debugged trying to understand how this works but the debugger doesn't stop always in all source code.
If f.i. you click on the screen I expected this to be an event, but the debugger didn't stop at all. Is there a command to always stop when a line of code is processed? Now it only stops when I have set a break point. I want to see every line processed...
I will try to implement your suggestions. For a newby it still looks difficult I hope someday I will look back to this and say "wow, that was so easy".
Click to expand...
Click to collapse
Well, actually that's the reason why breakpoints exist. To stop the debugger and allow you look at the running code..... or what else did you think??
RAMMANN said:
Well, actually that's the reason why breakpoints exist. To stop the debugger and allow you look at the running code..... or what else did you think??
Click to expand...
Click to collapse
I want to say "stop and show at the current code line".
For example you start your program, goto the appropiate window, type in some data and NOW before you click on SAVE. You say to your debugger "catch this/coming event".
Debugger would stop if you'd handle this event and set break point to 1st command of this function.
then yo can go step by step through each line of code.
and hey: it's not soo easy,which I posted.But your Compiler (vs2008 or PellesC or whatever) would make this automatically for you and you only have to copy your part of code into WinMain of this automatic processed code.
The "Managers" then can help you also to add eventhandlers automatically.
you only have to set Breakpoints to the automatic processed Event-Handle-Function - them you can see,if this event is triggered like you want it.
You only think from the wrong direction
Ok, I learned a lot.
(The VS2008 debugger has bugs. If I set a breakpoint on line 100, and start debug, line 109 has the breakpoint. It looks like only the original code can be debugged)
I did start a new project and used the tips from above. I can catch a click on a link ahref field in the notification bubble.
I have disabled the screen so only the bubble is shown
Now I need to catch the menu button and more important the data in the html form (input type radio) in the notification bubble. For this I need to convert the param to a structure...!
I also need to extend the "while getmessage" loop with a timer. If 15 seconds have passed, I need to step out of the loop and quit automatically.
A lot of searching again.
BTW.
Thx all for helping me. Not really one tip did it, you all guided me a bit. If you think your tip helped me a lot then send me a PM with your paypal code. You can also send me your address/or your businessaddress. I will send you a small present/surprise related to my country (Holland).
in Germany we have a good cheese, too and the sense of a community like this great one,is for helping each other-especially beneath developers.
And it's always a question of finding out,how to manage something new
All the best for your further development.
Micha
Attached is the code of my subproject. I will update it if those last points are done. Hope it helps others.
If someone has a link or example code for those points. (or improvements of my code) please let me know.
I wrote this utility to batch import hi-res contact photos (256x256 or whatever you want) to my contacts. The trick is to name the jpg files "firstname_lastname.jpg" so it will find a match.
I am not a programmer, so don't be too hard on me. I've learned a lot from xda-developers and just want to give a little back. Hope you like it.
contact_pictures.exe v1.0 (unzip and run it on your diamond, no cab, no install)
Source Code is shown below, NET CF on Visual Studio 2005 VB
' --- source code ---
' Joe Jones
' 6/16/10
Public Class Form1
Dim cnt As Integer
Dim AppSession As New Microsoft.WindowsMobile.PocketOutlook.OutlookSession
Dim myContacts As Microsoft.WindowsMobile.PocketOutlook.ContactCollection = AppSession.Contacts.Items
Dim session As Microsoft.WindowsMobile.PocketOutlook.OutlookSession = New Microsoft.WindowsMobile.PocketOutlook.OutlookSession()
Dim contacts As Microsoft.WindowsMobile.PocketOutlook.ContactCollection = session.Contacts.Items
Dim contact
Dim PathStr As String
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
cnt = 0
TextBox2.Text = Str(myContacts.Count)
TextBox4.Text = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
End Sub
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
' parse through contacts looking for file to update pictures
Dim FirstNm, LastNm As String
' set folder for pictures
PathStr = TextBox4.Text
While cnt < myContacts.Count
FirstNm = myContacts.Item(cnt).FirstName
LastNm = myContacts.Item(cnt).LastName
TextBox2.Text = Str(cnt)
TextBox3.Text = FirstNm
TextBox4.Text = LastNm
' check for matching contact info with picture filename "firstname_lastname.jpg"
If System.IO.File.Exists(PathStr + "/" + FirstNm + "_" + LastNm + ".jpg") Then
myContacts.Item(cnt).SetPicture(PathStr + "/" + FirstNm + "_" + LastNm + ".jpg")
End If
' increment counter
cnt = cnt + 1
End While
' end app
TextBox3.Text = ""
TextBox4.Text = "Done"
End Sub
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
Me.Close()
End Sub
End Class
jonzjos said:
I wrote this utility to batch import hi-res contact photos (256x256 or whatever you want) to my contacts. The trick is to name the jpg files "firstname_lastname.jpg" so it will find a match.
I am not a programmer, so don't be too hard on me. I've learned a lot from xda-developers and just want to give a little back. Hope you like it.
contact_pictures.exe v1.0 (unzip and run it on your diamond, no cab, no install)
Source Code is shown below, NET CF on Visual Studio 2005 VB
Click to expand...
Click to collapse
Great, I will test it out soon. Thanks.
Here is the source code as a project so anyone can make it better and recompile it.
Putting the exe and jpg files into the same folder is the easiest thing to do.
Hi there,
Does anyone out there how to preserve/restore the transient state of a CheckBox and/or Radio button?
So far, I'm using the following code, working for textbox
Code:
Public Sub PreserveState_TextBox(ByVal TB As TextBox)
Dim buffer As String = String.Empty
If True = PhoneApplicationService.Current.State.ContainsKey(TB.Name) Then
buffer = TryCast(PhoneApplicationService.Current.State(TB.Name), String)
If Not String.IsNullOrEmpty(buffer) Then
TB.Text = buffer
End If
End If
End Sub
Public Sub RestoreState_TextBox(ByVal TB As TextBox)
If True = PhoneApplicationService.Current.State.ContainsKey(TB.Name) Then
PhoneApplicationService.Current.State.Remove(TB.Name)
End If
PhoneApplicationService.Current.State.Add(TB.Name, TB.Text)
End Sub
Is it possible to modify the above code to work for Checkbox and/or Radiobutton?
If not, any ideas?
So far, I've been trying the sample "Tombstoning" sample code from Microsoft without any luck...
Thanks in advance!
I have a little problem with converting a binary or hex (it's hard to tell which but it's listed as reg_binary type) registry value to a string so i can output it to a file. That's about it really other than giving you the code i developed. It generates an InvalidCastException Error.
Code:
[SIZE=2][COLOR=#0000ff]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Alarm1Days [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Byte[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\Microsoft\Clock\0"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"AlarmDays"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], (0))[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sw [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IO.StreamWriter = IO.File.CreateText(DirPath1)[/SIZE]
[SIZE=2]sw.WriteLine(RegHead)[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"[HKEY_LOCAL_MACHINE\Software\Microsoft\Clock\0]"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""AlarmDays""=Hex:"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + Alarm1Days.ToString.PadLeft([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"0"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]CChar[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]CStr[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](8))))[/SIZE]
[SIZE=2][SIZE=2]sw.Flush()[/SIZE][/SIZE]
[SIZE=2]sw.Close()[/SIZE]
I'd be very grateful if you guys would help with this. It's given me a nasty headache.
Hey M3PH,
Maybe this is not what you wanted but the below functions could be useful. I remember that I've used them in converting binary<->hex values in the past in one of my PC apps.
Code:
#Region "Decode/Encode Functions"
Function DecodeStr(ByVal str As String) As String
Dim dec_temp As String
Dim StrBuilder As New StringBuilder()
Dim bt64 As Byte() = Convert.FromBase64String(str)
For i = 0 To UBound(bt64) - 1
dec_temp = Convert.ToString(CInt(bt64(i)), 16)
If dec_temp.Length = 1 Then
dec_temp = 0 & dec_temp
End If
StrBuilder.Append(dec_temp & ",")
Next
dec_temp = Convert.ToString(CInt(bt64(UBound(bt64))), 16)
If dec_temp.Length = 1 Then
dec_temp = 0 & dec_temp
End If
Return StrBuilder.ToString & dec_temp
End Function
Function EncodeStr(ByVal str As String) As String
Dim enc_temp As String
Dim bt64 As Byte() = System.Text.Encoding.UTF8.GetBytes(str)
enc_temp = Convert.ToBase64String(bt64)
Return enc_temp
End Function
#End Region
Code:
'Using DecodeStr function in your example...
[SIZE=2][COLOR=#0000ff]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Alarm1Days [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE] [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = Registry.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"HKEY_LOCAL_MACHINE\Software\Microsoft\Clock\0"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"AlarmDays"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], (0))[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sw [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] IO.StreamWriter = IO.File.CreateText(DirPath1)[/SIZE]
[SIZE=2]sw.WriteLine(RegHead)[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"[HKEY_LOCAL_MACHINE\Software\Microsoft\Clock\0]"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""AlarmDays""=Hex:"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] & DecodeStr(Alarm1Days))[/SIZE]
[SIZE=2][SIZE=2]sw.Flush()[/SIZE][/SIZE]
[SIZE=2]sw.Close()[/SIZE]
Regards!
When calling the Registry.Getvalue() method against binary values, it returns an Array of 'Byte' values. In this case, the value for 'AlarmDays' is only one byte long, but it is actually a one element 'Byte' array. The compiler cannot implicitly convert from 'Byte()' to 'Byte' so it throws the invalid cast error.
Here's the fixed code:
Code:
Dim Alarm1Days As Byte() = Registry.GetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Clock\0", "AlarmDays", (0))
Dim sw As IO.StreamWriter = IO.File.CreateText(DirPath1)
sw.WriteLine(RegHead)
sw.WriteLine("[HKEY_LOCAL_MACHINE\Software\Microsoft\Clock\0]")
sw.Write("""AlarmDays""=Hex:")
For Each ByteValue As Byte In Alarm1Days
sw.Write(ByteValue.ToString("X2"))
Next
sw.WriteLine()
sw.Flush()
sw.Close()
The For Each - Next code section is able to deal with any length of binary value returned. In the case of a one byte value above, you could actually get away with:
Code:
sw.Write(Alarm1Days(0).ToString("X2"))
The For Each method is safer.
thanks steph. i'm on holiday atm so i'll try it out when i get home and let you know
So i tired out your code, steph and it works pretty well but there is one thing i'm having trouble with at the moment. The for each statement seems to never end the line so you end up with one really long single line instead of lots of short ones. In an attempt to correct this i did the following:
Code:
[SIZE=2]
sw.WriteLine(RegHead)
sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"[HKEY_LOCAL_MACHINE\Software\Microsoft\Clock\0]"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])
sw.WriteLine([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"""AlarmDays""=Hex:"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ByteValue [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Byte[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Alarm1Days
sw.Write(ByteValue.ToString([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"X2"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]))
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Next
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]sw.Write(vbCrLf)
[/SIZE]
But that makes the for each output appear on a new line on it's own and this also is not what i need. I need the value name and then the data one the same line in the output file. Any ideas on how to achieve this?
WriteLine() automatically adds a carriage return & line feed pair to the end of whatever input it is given.
Write() doesn't.
Change
sw.WriteLine("""AlarmDays""=Hex:")
to
sw.Write("""AlarmDays""=Hex:")
P.S. WriteLine() and Write(vbCrLf) are identical.
stephj said:
WriteLine() automatically adds a carriage return & line feed pair to the end of whatever input it is given.
Write() doesn't.
Change
sw.WriteLine("""AlarmDays""=Hex:")
to
sw.Write("""AlarmDays""=Hex:")
P.S. WriteLine() and Write(vbCrLf) are identical.
Click to expand...
Click to collapse
I should have noticed that. Thanks for giving me a poke
Hi, i want to read the signal stretch value; i have this code but it doesen't works. Any idea?
Dim regKey As RegistryKey = Registry.LocalMachine
regKey = regKey.OpenSubKey("HKLM\System\State\Phone\Signal Strength")
Dim val As Object = regKey.GetValue("")
MsgBox(val.ToString)
Thaanks!
A key generated using Registry.LocalMachine already has the 'HKLM' root, implied within it. You do not need to respecify it.
Try this, and while we are at it, let's do what the optimiser would do, during a 'release' build of the above code:
Code:
Dim regKey As RegistryKey = Registry.LocalMachine.OpenSubKey("System\State\Phone")
MessageBox.Show(regKey.GetValue("Signal Strength").ToString())
If you don't need to save the value returned for later use, and just want to output the value in the message box, this actually works!
Code:
MessageBox.Show(Registry.LocalMachine.OpenSubKey("System\State\Phone").GetValue("Signal Strength").ToString())
One line of code to bring them all, and in the darkness bind them!
Note that there is no error checking at all, in the above examples.