I need an Maxthon alpha tester or two…

I need a Maxthon user (and if you are not one you should be – it is an alterenative browser based around IE) to test a new browser plug in.

The newest version of the Google tool bar does not work in Maxthon. I use search Site ALL the times and search images ALMOST as much. Without those two items in Maxthon, it is missing some major features.

So, I’ve written a toll bar that will take the text in the search field and use it to do those extra searches that the Google Tool bar does. It even EXTENDS the google functionality because it will search the news page for info you type in there.

So, this is it at a barely functional level. Please try it and tell me if you come up with any flaws major or minor. I already have in the about box a list of 8 or 9 things I want to do before it reaches a beta level. Any feedback would be appreciated.


Here is the Zip: http://www.thecodecave.com/downloads/GoggleAlpha1.zip
Just extract it with paths to the Maxthon directory, the built in paths will put it where it belongs. Then just open a webpage in Maxthon and the tool bar will appear. (you have to be at a page for the tool bar to appear, if you’ve chosen not to have any page open on startup, the toolbar will appear when you open a page.

Here’s my recommended Gogglebar positioning:
Alpha 1


So if you have a web page open and look for Goggle in the toolbar menu it is not there? Well, for the same reason it requires a page to be open, it likewise requires the Goggle DLL to be registered. You should be able to do clicking Start>Run and pasting in a modified version of this:
regsvr32 “c:\program files\Maxthon\Plugin\Goggle\Goggle.dll”
That will of course have to point to the right director for Maxthon…

See unfortunately this is an IE plugin that works in Maxthon. Ideally, the IE dependency will be removed but i’m not sure how to do that ATM. That may not be fixible befor a beta release, but it is not a big deal if it comes with an installer…

Not sleeping for 8 hours a night? Good for you!

I found this to be a very interesting article. It turns out that my stressing myself about not ever getting 8 hours of sleep is probably doing more harm, than just staying up and doing what I want, does….

Original Article: Sleep Deprivation: The Great American Myth

Robin Lloyd
Special to LiveScience
Thu Mar 23, 12:00 PM ET

People who get only 6 to 7 hours a night have a lower death rate than those who get 8 hours of sleep. —From a six-year study of more than a million adults

Many Americans are sleep-deprived zombies, and a quarter of us now use some form of sleeping pill or aid at night.

Wake up, says psychiatry professor Daniel Kripke of the University of California, San Diego. The pill-taking is real but the refrain that Americans are sleep deprived originates largely from people funded by the drug industry or with financial interests in sleep research clinics.

“They think that scaring people about sleep increases their income,” Kripke told LiveScience.

Thanks to the marketing of less addictive drugs directly to consumers, sleeping pills have become a hot commodity, especially in the past five years. People worldwide spent $2 billion on the most popular sleeping pill, Ambien (zolpidem), in 2004, according to the BioMarket, a biotech research company.

Earlier this month, it was reported that some Ambien users are susceptible to amnesia and walking in their sleep. Some even ate in the middle of the night without realizing it.

Global sales for all sleeping pills, called hypnotics, will top $5 billion in the next several years.

The number of adults aged 20-44 using sleeping pills doubled from 2000 to 2004, according to Medco Health Solutions, a managed care company. Sleep problems are commonly reported in the elderly, but the increase in spending on sleeping pills was highest in this period for 10-19 year olds, possibly due to an association with medication for attention deficit hyperactivity disorder (ADHD).

Sleep on this

Still, more sleep is no guarantee for overall health, and more sleeping pills might not bring on either.

A six-year study Kripke headed up of more than a million adults ages 30 to 102 showed that people who get only 6 to 7 hours a night have a lower death rate than those who get 8 hours of sleep. The risk from taking sleeping pills 30 times or more a month was not much less than the risk of smoking a pack of cigarettes a day, he says.

Those who took sleeping pills nightly had a greater risk of death than those who took them occasionally, but the latter risk was still 10 to 15 percent higher than it was among people who never took sleeping pills. Sleeping pills appear unsafe in any amount, Kripke writes in his online book, “The Dark Side of Sleeping Pills.”

“There is really no evidence that the average 8-hour sleeper functions better than the average 6- or 7-hour sleeper,” Kripke says, on the basis of his ongoing psychiatric practice with patients along with research, including the large study of a million adults (called the Cancer Prevention Study II).

And he suspects that people who sleep less than average make more money and are more successful.

The Cancer Prevention Study II even showed that people with serious insomnia or who only get 3.5 hours of sleep per night, live longer than people who get more than 7.5 hours.

And there are questions about the effectiveness of sleeping pills. A study by researchers at Beth Israel Deaconess Medical Center and Harvard Medical School found that a change in sleep habits and attitudes was more effective in treating chronic insomnia, over the short- and long-term, than sleeping pills (specifically Ambien).

Night of the living dead

Until 15 years ago, sleeping pills were mainly addictive barbiturates (such as Seconal, Halcion, Qualude) and sedatives called benzodiazepines (Valium and Dalmane). For this reason, they were less popular and less prescribed. That changed in the early 1990s when Ambien, which is less addictive, came on the market. It acts on the same neural receptors as a benzodiazepine, but is safer. It is the only hypnotic drug Kripke recommends and then, only for fewer than four weeks. Other new hypnotic drugs are safe but ineffective, he says.

Most sleeping pills are recommended for short-term use, but lots of people take them frequently and become dependent upon them to fall asleep. Most sleeping pills, especially when taken over long periods of time, stay in the bloodstream, giving a hangover the next day and beyond, impairing memory and performance on the job and at home.

A time-release version of Ambien (Ambien CR) bound for the market and designed to prevent waking after 4 hours when the drug normally would wear off, along with one of the newest pills on the market, Lunesta, or eszopiclone, (designed for longer-term use) might be even more harmful in this way, Kripke says.

Hypnotic drugs have dangerous side effects, Kripke says. For one, they reduce fear of risky behavior, such as driving fast. Ironically, that could result in the inability to see that the sleeping pills are doing more harm than good over time.

A recent study published in the British Medical Journal showed that the risks of taking sleeping pills (benzodiazepines and other sedatives, in this case) outweighed the benefits among people over 60 in a series of studies carried out between 1966 and 2003. The pills helped people fall asleep and they slept more, but they were twice as likely to slip and fall or crash a car due to dizziness from the pills than they were to get a better night’s sleep.

Even the safest hypnotic drugs have strange side effects, as the alleged Ambien sleepwalkers showed.

And one over-the-counter approach, the hormone melatonin, was found by scientists at the University of Alberta, Canada, to be ineffective in treating jet lag and sleep trouble associated with medical problems. Studies also show it is associated with skin blanching in frogs, gonadal atrophy in small animals, and obesity in some mammals.

Are you sleeping?

The real number of Americans with sleep problems is unclear because the same figure—70 million—appears on National Institutes of Health documents from 2006 and from 1994. This catch-all category reportedly includes insomnia, jetlag, sleepwalking, bed wetting, night terrors, restless legs syndrome, narcolepsy and disordered breathing during sleep (called apnea).

The National Sleep Foundation, the source of many sleep surveys and statistics, has financial and institutional ties to sleeping pill manufacturers, according to the Sacramento Bee newspaper.

Sleep problems could be increasing, Kripke says, but there is no evidence for this. If they are increasing, it could be a result of less exposure to daylight (due to cable TV, the Internet, indoor gyms) and increasing obesity, which causes apnea. But he still recommends against taking sleeping pills in nearly all cases and in favor of improved sleep habits.

“Sleeping pills usually do more harm than good,” he says.

Some Serious Shut-eye
Improved sleep behavior and attitudes do more good than sleeping pills for the treatment of insomnia, experts at a recent National Institutes of Health Consensus Conference agreed, says Daniel Kripke of the University of California, San Diego. The changes he recommends:

  • Do not take sleeping pills. This includes over-the-counter pills and melatonin.
  • Don’t go to bed until you’re sleepy. If you have trouble sleeping, try going to bed later or getting up earlier.
  • Get up at the same time every morning, even after a bad night’s sleep. The next night, you’ll be sleepy at bedtime.
  • If you wake up in the middle of the night and can’t fall back to sleep, get out of bed and return only when you are sleepy.
  • Avoid worrying, watching TV, reading scary books, and doing other things in bed besides sleeping and sex. If you worry, read thrillers or watch TV, do that in a chair that’s not in the bedroom.
  • Do not drink or eat anything caffeinated within six hours of bedtime.
  • Avoid alcohol. It’s relaxing at first but can lead to insomnia when it clears your system.
  • Spend time outdoors. People exposed to daylight or bright light therapy sleep better.

HELP!!! Retrieving the handle of the DLL’s owner -HOW?

I have written a DLL, It needs to access a control in the instance of the application that loaded it. So, I want to get the handle of the application that is currently using that DLL. Or said a different way, the handle of the application that has loaded that instance of the dll. Anyone know how to do this? Solutions in any (major) programming language are acceptible. I should be able to readily translate them to Delphi…

I am building an Maxthon plug-in that adds the missing search buttons from the Google tool bar (search site, search news groups, search images). It is easy enough to search through all windows and get the handle of the maxthon window and then find the value you’ve put in the Maxthon search box. But I want to be certain that I get the right value. I could give myself a unique GUID, search all parent windows till I find that unique GUID and then know that that parent window is my host, however, that seems a pain….

Any thoughts?

The Best Pinger/Update Services List for WordPress 2.02

After some fairly exaustive research and testing, I have come up with the following combined pinger list for WordPress. This took four or five other lists and eliminated duplicates and slow responders (from the US). Many lists contain entries that are already available through Ping-o-matic which goes out and pings the pingers. At the time of this post, this list will not produce any duplicates and will allow WordPress to complete its post before the standard browser will time out. This WILL increase the time it takes to post, however you do not need to wait for the browser to refresh itself. You can usually move on to do other things after the first second or two. At that point the post has been made to the DB and WordPress is off notifying the pingers and will continue that until it is done.

Here is the list of Update Services I use at my blogs:


Put these in the “Update Services” field on the Options>Writing tab in your WordPress administrator control panel.

Loading/Unloading a registry hive programmatically in Delphi 5+

Concepts demonstrated:
Registry Use (See procedure TfrmLoadHive.btnDisplayValueClick(Sender: TObject))
Hives & The Default User hive & .Default (See below)
Executing another program from within a Delphi program (See procedure TfrmLoadHive.btnExecRegEditClick)
Use of Process Token Privileges in Delphi (See below)

RE: Hives
The WinXP registry is divided into many different sections. Each major section is called a hive. Handling complete branches of the registry as separate hives allows Microsoft to perform several neat tricks. First of all, it allows hive to appear in several places in the registry with different names. The most obvious example of this is HKey_Current_User which of course points to the hive of the user that has logged in. A lesser known example is HKEY_CLASSES_ROOT which is simply a reloaded version of KEY_LOCAL_MACHINE\SOFTWARE\Classes. Those familiar with the DOS subst command and Linux symbolic links can draw comparisons there too.

An even lesser known use of windows hives is that Windows does not keep all of its hives active. It has separate hives to use as examples for creating local users, and other for creating user accounts when someone has logged into the machine remotely through a domain. I seem to remember there being a couple more examples but they elude me at the moment. Those hives are stored as DAT files on the hard drive. For instance, in the default XP install, the registry hive stored at ‘c:\\Documents and Settings\\Default User\\NTUSER.DAT’ will be used to set all the default registry entries whenever a new user logs into the machine. Set a value in that hive, and all future users will have that value.

NOTE: Do not confuse this with HKEY_USERS\.DEFAULT. The HKEY_USERS\.DEFAULT hive stores the values used when no one is logged in. “Huh? How could that be useful?” Well, if you think about it, controlling whether or not a computer puts itself to sleep if some one has booted it but not logged in can be very important. It might also be nice to set a screensaver that works when you log out of your computer but leave it turned on. An ultra secure person could set the color scheme to be entirely black on black, then only a person that really knows what they are doing could log into the computer – LOL. In any case, .DEFAULT and the Default User hives are NOT the same thing.

RE: Token Privileges:
Windows XP/NT/2000 and newer operating systems have advanced security methods to restrict what programs can and cannot do. These restrictions also allow the logging of some restricted access functions. So, for example, while it is possible for programs to set the system time, just any old program can’t do it.

The program has to ask for and get permission to update the time, before it can be accomplished. It is a bit like what a bell hop must do to get into someone’s hotel room. If a bell hop needs to get into room 5321 (let’s pretend this hotel uses keys and not plastic cards), the bell hop will tell his manager he’s gonna need to get into a room, look up which key that room needs, ask the manager for that key, unlock the room and do his thing. Then of course he will lock the door as soon as he is done. Note that if the bell hop does a bunch of other things before locking the door, the room could be burglarized. And when a good bell hop has to access the room several times, the room will be locked between times he is accessing it.

The process for Windows is the same:
Tell Windows you will be adjusting privileges by calling: OpenProcessToken(GetCurrentProcess(),
Find the local name of the privilege you will be adjusting by calling LookupPrivilegeValue
Grant yourself access by setting TTokenPvg.Privileges[0].Attributes to SE_PRIVILEGE_ENABLED
Lock the door again by setting TTokenPvg.Privileges[0].Attributes to SE_PRIVILEGE_DISABLED

In my program, I have created three helper routines for working with the tokens: SetTokenPrivilege, GrantPrivilege and RevokePrivilege. The latter two only serve to make my calling code clear. Readability is essential for any professional grade program. At some point you will forget the details of every single program you’ve write. So, even if you are only writing a routine for your own use, you should do what you can to make it easier to read. Tasks like this may seem wasted on throw away programs, but the more you do it, the faster you will be and the more likely it will be that your habit of writing good code will pay off in the end.

Here are my Delphi privilege routines:

A helper function that enables or disables specific privileges on the
specified computer. A NIL in SystemName means the privilege will be granted
for the current computer. Any other value must match the name of a computer
on your network.
procedure SetTokenPrivilege(aSystemName: PChar; aPrivilegeName: PChar; aEnabled: Boolean);
TTokenHd: THandle;
TTokenPvg: TTokenPrivileges;
cbtpPrevious: DWORD;
rTTokenPvg: TTokenPrivileges;
pcbtpPreviousRequired: DWORD;
TokenOpened, ValueFound: Boolean;
begin // SetPrivilege
// The privilege system is only available on NT and beyond
if (Win32Platform = VER_PLATFORM_WIN32_NT)
then begin
// Retrieve the Token that represents this current application session
TokenOpened := OpenProcessToken(GetCurrentProcess(),

// Check for failure
if (not TokenOpened)
then raise Exception.Create(‘The current user does not have the access required to run this program.’)
else begin
// Get the name of the privilege (since Windows is multi-lingual, this must be done)
ValueFound := LookupPrivilegeValue(aSystemName, aPrivilegeName, TTokenPvg.Privileges[0].Luid) ;
TTokenPvg.PrivilegeCount := 1;

// Enable or disable the flag according to the bool passed
if (aEnabled)
then TTokenPvg.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED
else TTokenPvg.Privileges[0].Attributes := SE_PRIVILEGE_DISABLED; // See note on local constant declaration
cbtpPrevious := SizeOf(rTTokenPvg) ;
pcbtpPreviousRequired := 0;
if (not ValueFound)
then raise Exception.Create(‘This program is incompatible with the operating system installed on this computer.’)
else begin
// Adjust the permissions as required.
Windows.AdjustTokenPrivileges(TTokenHd, False, TTokenPvg, cbtpPrevious,
rTTokenPvg, pcbtpPreviousRequired);
raise Exception.Create(‘The current user does not have the required access to load a registry hive.’)
end; // SetPrivilege
This routine grants the privilege(s) needed to access the hidden system hive
and load it into memory.
procedure TfrmLoadHive.GrantPrivilege(aPrivilegeName: String);
begin // GrantPrivilege
SetTokenPrivilege(NIL, PChar(aPrivilegeName), TRUE);
end; // GrantPrivilege

This routine revokes privilege(s) given in GrantPrivilege
procedure TfrmLoadHive.RevokePrivilege(aPrivilegeName: String);
begin // RevokePrivilege
SetTokenPrivilege(NIL, PChar(aPrivilegeName), FALSE);
end; // RevokePrivilege

In my case, I am using the SeRestorePrivilege token. This is actually one of the most powerful and lethal tokens. With it you are telling Windows that you are a Hard Drive backup program and you want to have access to all sorts of files that most programs are not allowed access to. Presumably you are doing this for good and not evil. Other tokens are:
SeCreateTokenPrivilege, SeAssignPrimaryTokenPrivilege, SeLockMemoryPrivilege, SeIncreaseQuotaPrivilege, SeUnsolicitedInputPrivilege, SeMachineAccountPrivilege, SeTcbPrivilege, SeSecurityPrivilege, SeTakeOwnershipPrivilege, SeLoadDriverPrivilege, SeSystemProfilePrivilege, SeSystemtimePrivilege, SeProfileSingleProcessPrivilege, SeIncreaseBasePriorityPrivilege, SeCreatePagefilePrivilege, SeCreatePermanentPrivilege, SeBackupPrivilege, SeRestorePrivilege, SeShutdownPrivilege, SeDebugPrivilege, SeAuditPrivilege, SeSystemEnvironmentPrivilege, SeChangeNotifyPrivilege, SeRemoteShutdownPrivilege, SeUndockPrivilege, SeSyncAgentPrivilege, SeEnableDelegationPrivilege, SeManageVolumePrivilege
So, that’s the basics. Take a look a the comments in the rest of the source code and you’ll soon see what happens and why.

Also try some different things. Run RegEdit and load the hive manually through File>Load Hive. Did you notice that you HAVE to be at a point within one of the preloaded hives before that option is enabled? What happens when you press the load hive button but you haven’t granted yourself privileges? What happens when you grant your self privileges and don’t revoke them b4 closing the program. Can you then load the hive when you rerun the program? What happens if you Grant 4 time but only unload once?

Experiment. But remember, you are playing with the registry and thar be monsters there. This app works fine on my system, I’ve used similar routine regularly for a couple years now, but I haven’t tested it with all versions of Windows and I have no idea how it will handle out-of-the-ordinary circumstances, like bad sectors in a dat file on your HD. Additionally, a Windows Service pack could totally change what this program does. So, in short, don’t come to me when you need to reinstall Windows. I’ll simply say it was a bad coincidence and anyway your system is beyond my control, you never should have run this program on it. I’m not responsible for your financial and emotional loss. You are responsible for making sure that source code you run on your computer does not have deliberate or accidental malicious behaviors.


Cool stuff to look at on Google Satelite view

Have you ever explored the artic regions?

There’s some incredible stuff to see up there in satellite view, like icebergs the size of SW PA breaking off and flowing down stream…

I had been looking at Greenland then I became fascinated with this huge river up in Russia


This thing is absolute HUGE and look at the pockmarked land structure around that bay… it is just wild

And that river flows all the way back to/from this huge lake thousands of miles away – which has a really weird streak across it. http://maps.google.com/?t=k&ll=53.13359,108.676758&spn=2.017007,4.575806&t=k

It must be something on the satellite’s lens… You can see it’s fabric….

Even so, I am considering submitting a story to Weekly World News about how the Russians have a massive program to create a band-aid to patch the hole in the ozone… I think it would fly don’t you?