WinSparkle 라이브러리를 Windows Form 응용 프로그램에 사용해야합니다. 라이브러리 헤더 - <winsparkle.h>
을 포함하고 DLL 가져 오기 코드를 넣었습니다. 나는 Dll 가져 오기 코드가 C# 스타일이라고 가정합니다. C++ .Net
스타일로 변환하는 방법?Windows 응용 프로그램에서 라이브러리 사용
// AutoUpdate.cpp : main project file.
#include "stdafx.h"
#include "Form1.h"
#include <winsparkle.h>
using System;
using System::Runtime::InteropServices;
using namespace AutoUpdate;
namespace AutoUpdate // YOUR NAMESPACE CAN GO HERE
{
**// C# lines**
class WinSparkle
{
// Note that some of these functions are not implemented by WinSparkle YET.
[DllImport("WinSparkle.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern void win_sparkle_init();
[DllImport("WinSparkle.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern void win_sparkle_cleanup();
[DllImport("WinSparkle.dll", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)]
public static extern void win_sparkle_set_appcast_url(String url);
[DllImport("WinSparkle.dll", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.Cdecl)]
public static extern void win_sparkle_set_app_details(String company_name,
String app_name,
String app_version);
[DllImport("WinSparkle.dll", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)]
public static extern void win_sparkle_set_registry_path(String path);
[DllImport("WinSparkle.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern void win_sparkle_check_update_with_ui();
}
}
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}
그냥하지 마세요. C++/CLI의 요점은 pinvoke를 사용하지 않아도된다는 것입니다. 함수를 직접 호출하면됩니다. 컴파일러에서 .h 파일에 원시 코드 선언이 포함되어 있는지 확인하려면 #pragma managed (push, off) 및 #pragma managed (pop)로 #include를 래핑하십시오. –