Ronald Reagan may be America's second cowboy president, if you figure Hollywood sound stages as extensions of the western range that real cowboys rode. But he's been left out of the Library of Congress' new exhibition called "The American Cowboy," and don't think he didn't notice it last night.

"As I went along I kept looking and looking for something called 'Cattle Queen of Montana,' " Reagan joked to nearly 450 invited guests after taking a quick tour of the show with Nancy Reagan, Librarian of Congress Daniel Boorstin and Harry J. Gray, chairman of United Technologies Corp., which spent $200,000 to underwrite the exhibition.

"Cattle Queen of Montana," one of five cowboy movies Reagan made in his 25 years on the Hollywood scene, was filmed in 1955 with Barbara Stanwyck as his costar. "I wasn't the 'Cattle Queen,' Barbara Stanwyck was," he hastened to add, to the crowd's delight. "I also did one called 'Cowboy.' "

Actually, it was called "Cowboy From Brooklyn," but any mention of it or any of his other "B" cowboy films was deliberately left out of the show by guest curator Lonn Taylor.

"He did not really play a significant role in shaping the way people perceived the cowboys," said Taylor, a historian from Texas who wrote the show's script and chose the objects in the exhibition. "We were looking for images that were striking and delightful."

Reagan has traded on his western image in campaigns and while in the White House, and last night he did it again. He referred to his "fondness" for western art, his nostalgia for the symbols of the Old West and "the dream of our youth and the standards we aimed to live by in our adult lives, the ideas of courageous and self-reliant heroes--the stuff of western molds.

"The difference between right and wrong," the president said, "seemed as clear as the white hats cowboys in Hollywood movies wore so we'd know right from the beginning who the good guys were."

Though Reagan likes to portray himself as a white-hatted cowboy, Taylor said the president doesn't strike people as a real cowboy in his part of the country, the Southwest.

"In the East he's romanticized as a cowboy. In my part of the country he's seen as a successful politician. I perceive him as a film actor who has become a politician," said Taylor, adding that, in contrast, "Theodore Roosevelt was a cowboy who became a politician."

Roosevelt was the first genuine cowboy president, as the show amply documents in photographs and other displays. Among the items is a red bandanna designed as a campaign memento for Roosevelt. Reproductions of the scarf were given to both Reagans, formally attired for a later stop at the annual radio and television correspondents' dinner.

The Reagans promptly put the scarfs around their necks, taking a cue from the bandanna draped around the white marble neck of James Madison's statue. The larger-than-life statue served as the backdrop for the president's brief talk in the library's James Madison Memorial Building.

In opening the exhibit, Reagan cracked that "this may mark the beginning of a new era in Washington--some sorely needed horse sense. I can carry on from there, but I won't."

But politics seemed about as remote as the days of the old Rough Rider whose words have become America's defense policy off and on: Speak softly and carry a big stick. Compared with descriptions of "Star Trek"-like laser-beam defenses in outer space that Reagan advocated in Wednesday night's television speech, Roosevelt's motto seemed like old-fashioned gunslinger talk last night.

United Technologies' Gray, in a receiving line with Boorstin and William Welsh, deputy librarian, said he had heard Reagan's TV speech and thought it "very forceful."

Gray, who is in the same Bohemian Grove camp (Owl's Nest) with Reagan when the president attends the exclusive, all-male California get-togethers, said, "We must keep up a strong defense budget."

Last night, though, United Technologies' chief executive officer and others on his team were more preoccupied with "The American Cowboy," which opens to the public tomorrow and runs through Oct. 2.

United Technologies currently gives away $10 million a year, one third each to the arts, education and to health and welfare, said Raymond D'Argenio, the company's senior vice president.

Certainly no expense was spared at last night's party where there were oysters on the half shell, barbecued ribs, corn bread, fried spuds with cheese and sour cream topping, figs wrapped in prosciutto, fresh strawberries and assorted "red eyes" under more contemporary labels.

While the crowd milled about, the Riders of the Sky played such tunes as "Mexicali Rose" and "Ghost Riders in the Sky." Among the guests were country and western singer Patsy Montana, Attorney General William French Smith, Sen. Edward Zorinsky (D-Neb.), Supreme Court Justice Sandra Day O'Connor, former senator Eugene McCarthy, former ambassador Clare Boothe Luce, and former secretary of state Alexander M. Haig Jr., former chairman of United Technologies.

And receiving a steady stream of fans was western author Louis L'Amour, who stopped off in Washington while publicizing his latest book, "The Lonesome Gods." When the Motion Picture Association's Jack Valenti marveled at L'Amour's productivity (his books have sold 130 million copies to date), the writer grinned knowingly. "No end to them," he promised.

Not everybody got there in time to see the exhibit. Commerce Secretary Malcolm Baldrige, a rodeo qualified cowboy, missed it by minutes when it was closed to permit a security sweep of the area before the Reagans arrived. It provided a chance for reflections.

Did Baldrige think there were any western heroes around anymore, someone asked him.

"It depends upon how you define heroes," he said, after a pause.

"Ronald Reagan's from the West," suggested Dr. William S. Hughes, a Washington internist.

"There's a good answer--Ronald Reagan," said Baldrige. "My answer to that is Ronald Reagan."