Dorcas R. Hardy, headed for easy confirmation as Social Security commissioner, pledged yesterday to strengthen the system and back legislation that would block the secretary of the Treasury from dipping into system trust funds to maintain other government activities when the Treasury runs short.

Hardy made the statements at a Senate Finance Committee hearing on her nomination. Sen. William L. Armstrong (R-Colo.), sitting as chairman, predicted virtually unanimous Senate approval for her.

Hardy gave some but not all of the assurances about her future policies sought by committee members Daniel Patrick Moynihan (D-N.Y.) and John Heinz (R-Pa.) and by former secretary of health, education and welfare Wilbur J. Cohen, who also testified. She said:She would be willing to "relook at the numbers" if she finds that administration-proposed personnel cuts of 17,600 by 1990 would harm Social Security service levels.

But she told Heinz, "We can meet that target . . . through attrition" and continued improvement of computer and other systems. She hopes to be "a forceful advocate for Social Security" in personnel and funding bouts with the Office of Management and Budget, and will resist OMB attempts to force the personnel reduction if she thought it would hurt services. She favors leaving Social Security in the Health and Human Services Department, not making it an independent agency. She will try to develop objective standards to guide whether any of Social Security's 1,311 field offices will be closed. "We must maintain the fiscal integrity of the Social Security programs . . . provide the best service across the country that we know how . . . use the best technology available to administer the Social Security programs . . . emphasize education of the public so that people understand what they can expect from the system."

Moynihan and others have charged, with backing from a comptroller general's study, that the Treasury broke the law in temporarily taking $5 billion in 1984 and $25 billion in 1985 out of the Social Security trust funds that are to be used only to pay benefits and using the money in part to fund general government expenditures.

Hardy said she is "willing to support legislation . . . that limits the secretary's discretion" to divert Social Security trust funds to other purposes and believes that the Treasury is preparing such legislation.

Cohen, head of a huge coalition of organizations backing the program called Save Our Security, expressed concern that proposed staff cuts and possible closing of district offices would harm the system.

He also said that future such diversion of trust-fund money threatens the funds and should be absolutely barred, and that Social Security should be made an independent agency isolated from politics.