bztronics logo 

bztronics

Advanced Technology for Better Living
 

Home
Products
Upgrades
FAQ
Support
Store
Circuits
Code Tips
About Us
Contact


Powered By: Syntax



Code and Computer Tips

Windows 7 Tips

You may have experienced Windows 7 and became completely frustrated. What happened to the supposed fastest operating system yet? Here are the symptoms most are having after upgrading to Windows 7.

1. Long delays when opening media, mp3s movies etc...
2. Takes forever to view folders and pictures
3. Windows 7 poor overall performace


Not to worry...here's the main fix for Windows 7 slow issues.

STEP 1:


1. Open your Windows Start Menu and select Computer
2. Right Click the hard drive that Windows 7 is installed on and click Properties
3. UNCHECK the box that says "Allow files on this drive to have context indexed in addition to file properties"
4. Click Apply

Windows 7 Indexing

If a Message Box pops up select Ignore All. It will take a few minutes for Windows 7 to make the changes.

STEP 2:

1. Open the Windows 7 Control Panel and in the upper right corner select View By : Small Icons
2. Select "Administrative Tools"
3. Select "Services"
4. Scroll down to "Windows Search" and double click it
5. Stop the service
6. For the Startup Type - Select Disabled
7. Click Apply

Reboot your computer. You will see a huge increase in Windows 7 performance now.

Make your own application Help with the C++ Web Browser component

After 25+ years of programming, we've finally decided to make our own Help in our applications with common html files using a WebBrowser Component. To do this there is one hidden catch. To read local files you need to use the UNC format. A quick and easy way to do this is by using the command below...

Delphi - WebBrowser1.Navigate(ExpandUNCFileName('main.htm'));

C++ - WebBrowser1->Navigate(ExpandUNCFileName("main.htm"));

main.htm is your main Help file page with links to other topics. This may seem like more work, but it's really not and your customers will be very happy after a rogue Windows Update!

Here is a seriously easy and cool one liner to launch a web site or file from a form (Windows Updated 11-21-08 for XP and Vista)

C++

char* URL = "http://www.bztronics.com";
// Now just use ShellExecute to run it
ShellExecute( NULL, "open", URL, NULL, "C:\\", SW_SHOW );

If you are using Delphi in Rad Studio 2009...

uses ShellApi

ShellExecute( handle, 'open' , 'http://www.bztronics.com', ' ', ' ' , SW_SHOW);
 
Remember that this is just a simple Windows API call. The function will open any file that Windows
has as an association to. If it is web address it will open the default browser. If it is a text file, it will open Notepad. This ancient function has been switched around in the last versions of Visual Studio 2008 and Rad Studio 2007. If you use ShellExecute() from older code, you will have to rearrange a few things. Pay attention - this is tricky for beginners!

In RAD Studio 2010 or Visual Studio 2008, you can use a Link Button to get the same results.

HTTP with Java

Java and old J++ makes it very easy to do HTTP requests. You can use this code template as a guide when performing HTTP requests...

public void HTTP_Request()
{
try {
URL url = new URL(urlEdit.getText());//url
//setup http headers here
HttpURLConnection huc = (HttpURLConnection);
url.openConnection();
huc.setRequestMethod("POST");
huc.connect();
int code = huc.getResponseCode();
String response = huc.getResponseMessage(); //lblResponse.setText(urlEdit.getText()+ '\n'+ code +'\n'+ huc.getResponseMessage()); huc.disconnect(); //lblResponse.setText("");
}catch (IOException x) { show(); MessageBox.show("...Error Code...");}

}

One liner PHP to get an entire HTTP request document into a string variable

This is a cool one liner to get a web document into a string variable. This is very handy when you want to retreive an XML document or an RSS feed and use PHP parsing functions for dynamic web content.

$xm = file_get_contents('http://rss.news.yahoo.com/rss/mostviewedtc');

The entire html or XML document is contained in the variable $xm. Why would you use this? Many search engines increase page rank by how often content is changed, however many do not read "active content" from PHP or Java Scripts. You can use this little gem to create dynamic, updated HTML pages that all search engines recognize!

Optimizing 8051, PIC Microcontroller routines for speed

If you are using C to create your Micro Firmware, it is a good idea to drop into simple Assembly language routines to speed things up. As you probably already know, C handles stack routines automatically. Sometimes, the generated code is inefficient. This is because when you do a function call, ALL variables are automatically pushed to the FIFO stack. There are even more pushed to the stack when you cross a page boundary.

Fortunately, you can use Assembly routines to override the default C operations. There are many times when you do not need to push and pop all of your variables to and from the stack, as many will not change in the called function. Depending on your compiler, you may even be able to avoid #PRAGMA directives, if your compiler supports inline Assembly.

Before function call...

asm {
push  Variable_1 // first variable you NEED to save
push Variable_2 //second variable you NEED to save
push Variable_x // ...any more variables that NEED to be saved
}

//On return

asm {
pop  Variable_1 // first variable you NEED to recall
pop Variable_2 //second variable you NEED to recall
pop Variable_x // ...any more variables that NEED to be recall

}

Just be sure not to leave anything out. This is an advanced optimization method, yet simple enough to be easily implemented by greenhorns. Depending on your compiler, compiler directives may need to be added and a complete Assembly function can be written to handle this automatically. Happy Coding!

Murphy's Laws for Computer Geeks

  • Your computer will crash when you are doing the most important thing that you have ever done on a computer. You'll lose everything that you have been working on and everything that you had.
  • The most annoying porn site pop up window, with audio included, will show up when your spouse or boss are walking by, even if you have never seen a site like that in your life.
  • You will inevitably hit send on a email that will be accidentally sent to the last person on earth that you would want to read it.
  • After you finally get your software and installers working for a Windows operating system, Microsoft will release a new version of Windows, or throw out a new Automatic Update that will render everything you have done useless.
  • Hard drives will always permanently fail, with no hope of data recovery before you have backed up your files.
  • For every bug that you fix, two more bugs are automatically created...
  • When your software finally meets all original specifications, the specifications will change.

RSS

© bztronics 2009 All Rights Reserved