Hi everyone. A programmers notebook started out as a place for me to post things that I find on the internet for myself. I guess you could say that these have proven to be beneficial to everyone. Enjoy!
Thursday, November 4, 2010
C Sharp Windows Task with SCHTASKS
Tuesday, November 2, 2010
Beginning Programming: File Listener Application Part I
2. We need to add several using statements to the beginning of our form.

Wednesday, March 10, 2010
Windows System Tray and Startup Applications
This tutorial is simple, I will show you how to run your app in the background at startup and in the system tray. You should have already built or compiled your app into an exe file.
1. The first step is add a Notifyicon control and a Context Menu control from the toolbox to your windows form.
2. Go to the properties of the Notifyicon control and set the properties of that control.
3. Go to the properties of the Context Menu control and Right click the control and choose Edit. Since this menu will appear when your right-click the icon in the system tray, you will want to add an Exit menu item.
4. Now that you have the Exit menu (button) double click to add the event to the forms code. Then add the following code to close the application.
Application.Exit();
5. Now let's control the Form. Set the following to the Form property window.
FormBorderSize: Fixed Tool Window
WindowState: Minimized
Opacity: 0%
ShowInTaskbar: False
Now that the application is configured for the system tray, rebuilt your app and run it. The application should show in the system tray. Note, the main form cannot be used as an application form. Create another form in your application and call that form, adding an additional item in the Context Menu to do other things.
Configuring the application to run at Windows startup
Now, let's configure the application to start when the user logs in.
To make an application run at every startup, create a shortcut to the application and place the shortcut in the Startup folder of the user who will log on or under the ALLUSERS Profile.
Click Start, Run and type:
%userprofile%\Start Menu\Programs\Startup
This opens the Startup folder of your user profile. Now, right-click the folder and choose New, Shortcut and type the path for the filename which you want to execute at startup. You can simply drag the application shortcut also. This affects only your user profile startup.
To have the application run at startup for every user who logon to the computer, place the shortcut in this path instead:
%allusersprofile%\Start Menu\Programs\Startup
Wednesday, February 24, 2010
Creating a C# Windows Service
Let's begin:
Launch Visual Studio

Step 1: Create a Skeleton Project
File > New > Project
A new project dialog box will appear giving you options for creating a new project.
Let's narrow down the project type.
From the tree view on the left side of the dialog box select Windows.

This will only display Templates for creating Windows projects. Select Windows Service

Step 2: Project Name & Settings
Give your windows project a name, then click OK to create your project.
Your project Window Window will look like this:

Set your ServiceName to your own name so that you will recognize it when you look at services in Computer Managerment under Services tree. I used LMCListener as my service name. It might be difficult to find the properties to do that. Here is what you do. When the project wizard is completely launched, the first window that appears is the Design View for Service1.cs. Your properies will most likely not display the Service Processes so, simply move your mouse to the Service1.cs tab at the top of your project winds, then in the Properties you will then see ServiceName at the bottom of the list.
Step 3: Adding code to the code view, right click on the gray area of the Service1.cs window and choose View Code
That will give you the following:

I've provided you with some sample code to help you create your first project. Here's the code below:
protected override void OnStart(string[] args)
{
FileStream fs = new FileStream(@"c:\temp\mcWindowsService.txt",
FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter m_streamWriter = new StreamWriter(fs);
m_streamWriter.BaseStream.Seek(0, SeekOrigin.End);
m_streamWriter.WriteLine(" mcWindowsService: Service Started \n");
m_streamWriter.Flush();
m_streamWriter.Close();
}
protected override void OnStop()
{
FileStream fs = new FileStream(@"c:\temp\mcWindowsService.txt",
FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter m_streamWriter = new StreamWriter(fs);
m_streamWriter.BaseStream.Seek(0, SeekOrigin.End);
m_streamWriter.WriteLine(" mcWindowsService: Service Stopped \n"); m_streamWriter.Flush();
m_streamWriter.Close();
}
Now Build your application which will produce an exe file located in the debug > bin folder of your project.
Step 4: The next step would be to Install and Run the Service.
You will do that using an install utility provided as part of the .NET Framework. But before we can install the service let's add some additional features to our service.
I'm not saying that our service is nonfunctional. It will work as is, but what if we want to have the service description and other things show up in our processes panel, or Services Panel. Here's the trick.
If you are not on the Service1.cs Design window, then go there. Now right click on the gray area of the window and choose Add Installer. The Installer objects will be added to your Design window at the top left corner.
There will be two files in that location: ServiceProcessInstaller1 and ServiceInstaller1, both will need their properties configured.
ServiceProcessInstaller1 - Account, this is the user account that the service will run under, set this to LocalSystem.
ServiceInstaller1 - Description, this is the description that will appear in the services admin tool. Set this to Empty Service Description
ServiceInstaller1 - Display Name, this is the service name that will appear in the services admin tool. Set this to Empty Service
ServiceInstaller1 - ServiceName, Set this to EmptyService.
ServiceInstaller1 - StartUpType, this determines whether the service will start automatically with windows, set this to Manual
Alright, thats it, you cannot run a service as you would a windows program. The .net framework has provided a tool that will install the service for you. The InstallUtil.exe program is located in the framework folder. From the command prompt type:
%Windir%\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe C:\YourServiceName .exe
where C:\YourServiceName .exe is the path to you service, to uninstall the service type:
%Windir%\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe /u C:\YourServiceName .exe
Once your service is installed you will find it in the Services admin tool by typing Services.msc at the run prompt:
Note make sure C:\YourServiceName contains the entire path to the exe file your created.
Monday, February 22, 2010
Fake A Call Palm WebOS Application
It had a rating of 5 on the 5th day of release. But today, someone posted but did not rate. It's so interesting to me that people would take the time out to destroy another persons reputation to promote their own interest.
Someone did the same thing with my first two applications by telling people, the app destroyed my phone or I downloaded this app several times and it doesn't work.
People are driven by perception and do think for themselves. Palm checks every application that comes through. If the application would destroy a mobile phone, then Palm would be liable and replace the phone and remove the application.
There are legal restrictions and such that we developers must abide by. The tactics of other developers who are competing, well God is watching. One thing that I know for sure, that Whom The Lord Blesses, no man can curse. God will turn their curse against them.
So, for those who are developers or non-developers who wish to harm another person at their own interest. You will suffer, it may not be financially, or something you see with your eyes. But you will not know true peace.
Think of it like this. If a chain is around your neck all your life and a free person came along and said that you are bound. Would you know it? Of course not, you've never known freedom. Some people in boundage will work to have freedom while still in chains. And will associate change as freedom.
Anyway, I'm gone for today. Hey, check out my church website too:
Notepad++ and XML Formatting
I guess when the mind thinks notepad, we think limited app.
Anyway, lately I've been working with lots of XML inside of a table. I've been copying xml files and pasting them into Visual Studio and working from their. But VS 2008 takes a long time to load and all I want to do is look at the XML file and code against it.
So I opened Notepad++. This is when I ran into a problem. The text pasted as one long string on line 1.
I searched for a method for formatting the xml. The web suggested Tidy. I downloaded the command line tidy.exe and that was out of scope. I didn't want to use two apps to accomplish formatting text, so I did additional searches and discovered that, in the new addition of Notepad++, tidy is included. That is version 5.6.6.
This is how to format your XML files.
In Notepad++ choose
> TextFX
> HTML Tidy
>Tidy Reindent XML
and the beauty of a thing is revealed.
Thursday, February 18, 2010
Palm WebOS
I already knew HTML, Javascript, JAVA, C#, CSS, ADO.NET, ASP.NET, AJAX, SQL, MYSQL, PHP, and some C and C++. So I needed a language that didn't require me to start over again.
Palm WebOS became exciting to me. I was one of the first developers to port my application to the Pre. It was difficult at first because I needed to learn the syntax of a few languages I've never encountered before.
SQLite, Mojo, JSON, Prototype! What in the world are these? One of the problems learning a new language when you know so many is that you have to almost become a child to learn the new, otherwise you will automatically try to solve the new development problems using the same language structure of the old.
Just like not knowing about coding, and learning a new language has its restraints and learning curve.
What I've learned about UI development for Palm WebOS has increased my UI development for desktop and web apps; I don't have words to express the appreciation.
Programming for the Pre and Pixie requires a UI developer to create an environment that is simple and yet communicates exactly what the user needs to know. Don't make me think.
If a person has to think about what they are doing, then the application is not working. I've purchased and downloaded free applications from the Palm Catalog and could not figure out what to do.
There was one gun application that tried to tell me to cock the rifle by holding the phone up and pushing forward. It didn't work. I couldn't figure it out. I read in detail, wrote it down and nothing worked. Either the app was broke or I was dumb.
Anyway, I've been developing UI and coding for more than 10 years and learned a great deal about what people want and how to speak to them with my applications. I am happy that Palm came out with such a great roadmap.
It doesn't take a lot of my time to develop a great application. I created my third application in 4 days. It's called Fake A Ring!
To all those who wish to learn and make money having fun. It's a great place to be.