public static WPS_ReturnCode WPSLocation(String realm, String userName, out Double latitude, out Double longitude) { WPS_ReturnCode result = WPS_ReturnCode.WPS_ERROR; //create and initialize the authentication structure WPS_SimpleAuthentication authentication = new WPS_SimpleAuthentication(); authentication.realm = realm; authentication.username = userName; //set to no address lookup WPS_StreetAddressLookup streetAddressLookup = WPS_StreetAddressLookup.WPS_NO_STREET_ADDRESS_LOOKUP; //Create location and pointer to it. WPS_IPLocation location = new WPS_IPLocation(); IntPtr buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(location)); Marshal.StructureToPtr(location, buffer, false); try { result = WPS_ip_location(ref authentication, streetAddressLookup, buffer); } catch (Exception) { } finally { Marshal.FreeCoTaskMem(buffer); } //these are 'out' variables from the custom function. so they need to be set latitude = 0; longitude = 0; if (result == WPS_ReturnCode.WPS_OK) { latitude = location.latitude; longitude = location.longitude; } return(result); }
private static extern WPS_ReturnCode WPS_ip_location(ref WPS_SimpleAuthentication authentication, WPS_StreetAddressLookup street_address_lookup, [Out] IntPtr buffer);
private static extern WPS_ReturnCode WPS_location( ref WPS_SimpleAuthentication authentication, WPS_StreetAddressLookup street_address_lookup, ref WPS_Location location);