Instructions
Check your Game Boy Color game's documentation to see if it supports the infrared port feature.
Start your game and proceed to the part of the game that utilizes the infrared port (in the aforementioned Pokémon example, you would choose "Mystery Gift" from the main menu). Note that both Game Boy Color systems need to have the game inserted for the feature to work.
Align the two Game Boy Color systems using the raised triangle (just above the screen) as a guide. Place them on a flat surface for increased stability, and ensure they're no more than 1.5 to 2 inches apart. Keep the infrared connection free from any obstructions or direct sunlight.
Follow the on-screen instructions to make the connection (in the Pokémon example you would press the "A" button to swap mystery gifts with your friend).