MARTINSBURG, W.Va. — The Bureau of Alcohol, Tobacco, Firearms and Explosives has been without a permanent director for six years, as President Obama recently noted. But even if someone were to be confirmed for the job, the agency’s ability to thwart gun violence is hamstrung by legislative restrictions and by loopholes in federal gun laws, many law enforcement officials and advocates of tighter gun regulations say.

For example, under current laws the bureau is prohibited from creating a federal registry of gun transactions. So while detectives on television tap a serial number into a computer and instantly identify the buyer of a firearm, the reality could not be more different.

When law enforcement officers recover a gun and serial number, workers at the bureau’s National Tracing Center here — a windowless warehouse-style building on a narrow road outside town — begin making their way through a series of phone calls, asking first the manufacturer, then the wholesaler and finally the dealer to search their files to identify the buyer of the firearm.

About a third of the time, the process involves digging through records sent in by companies that have closed, in many cases searching by hand through cardboard boxes filled with computer printouts, hand-scrawled index cards or even water-stained sheets of paper.