c++;方法从c#dllimport调用返回0
我正在调用函数,我得到的是0,这是第三方软件,已经使用多年,所以我知道它是正确的。这里是C++头文件:c++;方法从c#dllimport调用返回0,c#,c++,reference,return-value,dllimport,C#,C++,Reference,Return Value,Dllimport,我正在调用函数,我得到的是0,这是第三方软件,已经使用多年,所以我知道它是正确的。这里是C++头文件: #ifdef __cplusplus extern "C" { #endif int __stdcall initialise(); int __stdcall closedown(); int __stdcall WGS84ToLocal(double * lat, double * longt, int d); int __stdcall LocalToWGS84(double * lat
#ifdef __cplusplus
extern "C" {
#endif
int __stdcall initialise();
int __stdcall closedown();
int __stdcall WGS84ToLocal(double * lat, double * longt, int d);
int __stdcall LocalToWGS84(double * lat, double * longt, int d);
int __stdcall OSGB36ToOSGBGrid(double lat, double longt, double * east, double * north);
int __stdcall OSGBGridToOSGB36(double east, double north, double * lat, double * longt);
这是我的密码
class Program
{
public static double lon = 50.82011492;
public static double lat = 0.117981131;
public static double north = 50.82011492;
public static double east = 0.117981131;
public static Int32 OGB_M = 150;
public static int iErr = 0;
[DllImport("TTDatum3.Dll", EntryPoint = "WGS84ToLocal", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
public static extern Int32 WGS84ToLocal([In, Out]ref double lat, [In, Out] ref double lon, Int32 datum);
[DllImport("TTDatum3.Dll", EntryPoint="LocalToWGS84", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
public static extern Int32 LocalToWGS84([In,Out]ref double lat,[In,Out] ref double lon, Int32 datum);
[DllImport("TTDatum3.Dll", EntryPoint = "OSGB36ToOSGBGrid", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
public static extern Int32 OSGB36ToOSGBGrid( double lat, double lon, [In,Out] ref double east, [In,Out] ref double north);
[DllImport("TTDatum3.Dll", EntryPoint = "OSGBGridToOSGB36", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
public static extern Int32 OSGBGridToOSGB36(double east, double north, [In,Out] ref double lat,[In,Out] ref double lon);
public static void Main(string[] args)
{
iErr = OSGBGridToOSGB36(east, north, ref lon, ref lat);
Console.WriteLine(iErr);
iErr = LocalToWGS84(ref lon, ref lat, OGB_M);
Console.WriteLine(iErr);
}
你的主方法与上面的方法的lat和lon顺序相反。不知道这是否是您的问题的原因,但这是一个输入 你希望艾尔回来干什么?
请修复该部分,然后提供更新。在我刚刚测试的时候没有关系,ierr将返回一个从OSGB36到WGS84的转换长lat