The Wiener index of a connected graph G is W(G)=(& sum;)({u,v}subset of V(G))dG(u,v). In this paper, we obtain the Wiener index of H-generalized join of graphs G(1),G(2),& mldr;,G(k). As a consequence, we obtain some earlier known results in [Alaeiyan et al. in Aust. J. Basic Appl. Sci. (2011) 5(12): 145-152; Yeh et al. in Discrete Math. (1994) 135: 359-365] and we also obtain the Wiener index of the generalized corona product of graphs. We further show that the ideal-based zero-divisor graph Gamma I(R) is a H-generalized join of complete graphs and totally disconnected graphs. As a result, we find the Wiener index of the ideal-based zero-divisor graph Gamma I(R)and we deduce some of the main results in [Selvakumar et al. in Discrete Appl. Math. (2022) 311: 72-84]. Moreover, we show that W(Gamma I(Z(n))) is a quadratic polynomial in n, where Zn is the ring of integers modulo n and we calculate the exact value of the Wiener index of Gamma Nil(R)((R)), where Nil(R) is nilradical of R. Furthermore, we give a Python program for computing the Wiener index of Gamma I(Z(n)) if I is an ideal of Zn generated by p (R), where p (R) is a proper divisor of n, p is a prime number and r is a positive integer with r >= 2.