Using Heegaard Floer homology, we construct a numerical invariant for any smooth, oriented
4
4
-manifold
X
X
with the homology of
S
1
×
S
3
S^1 \times S^3
. Specifically, we show that for any smoothly embedded
3
3
-manifold
Y
Y
representing a generator of
H
3
(
X
)
H_3(X)
, a suitable version of the Heegaard Floer
d
d
invariant of
Y
Y
, defined using twisted coefficients, is a diffeomorphism invariant of
X
X
. We show how this invariant can be used to obstruct embeddings of certain types of
3
3
-manifolds, including those obtained as a connected sum of a rational homology
3
3
-sphere and any number of copies of
S
1
×
S
2
S^1 \times S^2
. We also give similar obstructions to embeddings in certain open
4
4
-manifolds, including exotic
R
4
\mathbb {R}^4
s.