Solar microwave bursts carry information about the magnetic field in the emitting region as well as about electrons accelerated during solar flares. While this sensitivity to the coronal magnetic field must be a unique advantage of solar microwave burst observations, it also adds a complexity to spectral analysis targeted to electron diagnostics. This paper introduces a new spectral analysis procedure in which the cross-section and thickness of a microwave source are expressed as power-law functions of the magnetic field so that the degree of magnetic inhomogeneity can systematically be derived. We applied this spectral analysis tool to two contrasting events observed by the Owens Valley Solar Array: the SOL2003-04-04T20:55 flare with a steep microwave spectrum and the SOL2003-10-19T16:50 flare with a broader spectrum. Our analysis shows that the strong flare with the broader microwave spectrum occurred in a region of highly inhomogeneous magnetic field and vice versa. We further demonstrate that such source properties are consistent with the magnetic field observations from the Michelson Doppler Imager instrument onboard the Solar and Heliospheric Observatory (SOHO) spacecraft and the extreme ultraviolet imaging observations from the SOHO extreme ultraviolet imaging telescope. This spectral inversion tool is particularly useful for analyzing microwave flux spectra of strong flares from magnetically complex systems.