掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
インスタンスメソッドを関数ポインタとして渡す方法 (ID:69217)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
試したところ、Marshal::GetFunctionPointerForDelegateを使えば メンバ変数もできるっぽいです。 using namespace WindowsApplication; using namespace System::Runtime::InteropServices; struct structA { void (*f)(); }; public ref class classA { int n; void func() { MessageBox::Show(n.ToString()); } delegate void Func(); public: void test() { structA s; n = 10; Func^ f = gcnew Func(this, &classA::func); IntPtr p = Marshal::GetFunctionPointerForDelegate(f); s.f = static_cast<void (*)()>(p.ToPointer()); // 実験 (*s.f)(); } };
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.