I was wondering how to make a program that when I plug in my USB drive the console then spits out a specific passcode that is set in the USB itself.(i am on windows 10 with visual studio 2017)
EnumPorts is for printer ports on a server, I don't think that is what you want.
I'm assuming that you want your program running. It gets notified when a USB drive is plugged in, so it can retrieve and display the passcode. For that you probably want the RegisterDeviceNotification function.