thanks again from Joel Ivory Johnson
and solution.....
Code Snippet
const string GPS_DEVICE_NAME_PATH = "DRIVERS\\Builtin\\GPSID";
public string GpsDeviceName
{
get
{
if (_gpsDeviceName == null)
{
RegistryKey gpsInfoKey = Registry.LocalMachine.OpenSubKey(GPS_DEVICE_NAME_PATH);
if (gpsInfoKey != null)
{
try
{
_gpsDeviceName = String.Format("{0}{1}:", gpsInfoKey.GetValue("Prefix"), gpsInfoKey.GetValue("Index"));
}
catch { }
}
}
return _gpsDeviceName;
}
}
private void Form1_Load(object sender, EventArgs e)
{
CoreDLL.PowerPolicyNotify(PPNMessage.PPN_UNATTENDEDMODE, -1);
CoreDLL.GetDevicePower(GpsDeviceName, DevicePowerFlags.POWER_NAME, out currentPowerState);
_gpsPowerRequirements = CoreDLL.SetPowerRequirement(GpsDeviceName, CEDEVICE_POWER_STATE.D0, DevicePowerFlags.POWER_NAME, IntPtr.Zero, 0);
}
private void Form1_Closing(object sender, CancelEventArgs e)
{
_gpsDevice.Close();
CoreDLL.PowerPolicyNotify(PPNMessage.PPN_UNATTENDEDMODE, 0);
CoreDLL.ReleasePowerRequirement(_gpsPowerRequirements);
}