Let $X_1,X_2,\ldots$ be i.i.d. random variables with common mean $\mu \geq 0$ and associated random walk $S_0 = 0, S_n = X_1 + \cdots + X_n, n \geq 1$. For a regularly varying function $\phi(t) = t^\alpha L(t), \alpha > -1$ with slowly varying $L(t)$, we consider the generalized renewal function $U_\phi(t) = \sum_{n \geq 0} \phi(n)P(S_n \leq t),\quad t \in \mathbb{R},$ by relating it to the family $\tau = \tau(t) = \inf\{n \geq 1: S_n > t\} t \geq 0$. One of the major results is that $U_\phi(t) < \infty$ for all $t \in \mathbb{R}, \operatorname{iff} \phi(t)^{-1}U_\phi(t) \sim 1/(\alpha + 1)\mu^{\alpha + 1}$ as $t \rightarrow \infty, \operatorname{iff} E(X^-_1)^2\phi(X^-_1) < \infty$, provided $\phi$ is ultimately increasing $(\Rightarrow \alpha \geq 0)$. A related result is proved for $U_\phi(t + h) - U_\phi(t)$ and $U^+_\phi(t) = \sum_{n \geq 0}\phi(n)P(M_n \leq t)$, where $M_n = \max_{0 \leq j \leq n} S_j$. Our results form extensions of earlier ones by Heyde, Kalma, Gut and others, who either considered more specific functions $\phi$ or used stronger moment assumptions. The proofs are based on a regeneration technique from renewal theory and two martingale inequalities by Burkholder, Davis and Gundy.