RICHMOND - Virginia's governor on Monday closed a loophole that allowed a mentally disturbed Virginia Tech student to buy the guns he used to kill 32 Tech students and faculty on April 16.

Gov. Timothy M. Kaine signed an executive order requiring that anyone ordered by a court to get mental health treatment be added to a state police database of people barred from buying guns.

A court in 2005 ordered out-patient counseling for Seung-Hui Cho after he was judged mentally ill and a danger to himself. But because he was not committed to a mental hospital, he was never entered into the database that licensed gun dealers use to do instant background checks before any sale. People judged as mental defectives can't legally buy guns.

Kaine's executive order, the first change in state policy resulting from the shootings, eliminates the distinction between inpatient and outpatient mental health care as long as it is ordered by a court.

Virginia already is the leading state in reporting mental health records, with more than 80,000 in the federal database. Twenty-eight states do not supply any records, either because they lack the technical ability or are barred by state privacy laws.

After the report is added to Virginia's state police database, it becomes part of a federal database that gun dealers nationwide use.

"The key criteria that should trigger the report is the finding of danger. If somebody had been determined mentally ill and they are determined to be a danger to themselves or others to such a degree that they are ordered to receive involuntary treatment," Kaine said at a news conference with Attorney General Bob McDonnell.

"Whether that treatement is to be provided in an inpatient or outpatient facility is of no moment," Kaine said. The executive order does not apply to people who seek mental health care of their own will. Cho, a 23-year-old Tech senior who killed himself as police stormed a classroom building, bought his guns legally at gun shops. Had Kaine's order been in place a year ago, the background check could have flagged Cho when he tried to buy a weapon from a licensed dealer. Cho did not disclose his mental health problems or the court-ordered outpatient treatment in a form he was required to complete before buying the guns. "His lie on the form would have been caught," Kaine said. But it would not prevent Cho from acquiring guns by several other means that require no background check in Virginia, including buy-and-trade publications, individual transactions among gun collectors or hobbyists and gun shows - vast firearms bazaars where scores of people sell or swap firearms. Legislation that would also subject firearms sales at gun shows to instant background checks is introduced perennially in Virginia, and just as often it dies without reaching a floor vote in the pro-gun rights General Assembly. Kaine, a Democrat, said in an interview last week he expects new emphasis behind the legislation this year and that he would support it as he has in the past. McDonnell, a Republican expected to run for governor in 2009, would not say Monday whether he would support such a measure. How long someone involuntarily ordered to submit to psychiatric care remains on the database depends on when or whether those people are once again judged fit and no danger to themselves or others, Kaine said. The bottom half of the form that a court uses to involuntarily order mental health services is later used to remove the same person from the database. Kaine said the state has a good track record of removing names from the database the state police maintain once a court has judged someone on the list as being well. "I've got to acknowledge that we feel a lesser degree of confidence with respect to the federal database. We can control what goes in and what comes out of the state database," Kaine said. "Once things come out of the state database, it is not clear that they are automatically coming out of the federal database and that is something we need to talk about with our congressional delegation." In another development, the last person hospitalized with injuries from the shootings was updated Monday from serious to fair condition, said Carilion Roanoke Memorial Hospital spokesman Eric Earnhart. Sean McQuade, 21, of Mullica Hill, N.J., was hit with five bullet fragments, family members said. He was among 25 people injured during the attack. AP-CS-04-30-07 1619EDT