Question: I found the [InterlockedExchange](http://msdn.microsoft.com/en-us/library/windows/desktop/ms683590%28v=vs.85%29.aspx) function which allows me to exchange two **signed** 32-bit variables (LONG).

But, what is the correct way to atomically exchange two **unsigned** 32-bit variables (ULONG) under Windows?

I do not see an obvious way to do that using the functions provided by Microsoft.

(Considering that Microsoft also tells me that the result of converting unsigned integers to signed integers is [implementation-defined](http://msdn.microsoft.com/en-us/library/e9s326kw%28v=vs.110%29.aspx) in some cases.)

Answer: 
Simply use a type-cast:

```
ULONG value1, value2;
InterlockedExchange((LPLONG)&value2, (LONG)value1);

```
In your link, casting a unigned something to types of different sizes  

(and/or floting point stuff) is explained.  

Casting only between signed and unigned of the same type  

should be possible without any problems.