PDA

View Full Version : سوال: InteropServices.DllImport به صورت داینامیک و فانکشن پذیر



papa_toop
چهارشنبه 23 دی 1394, 09:52 صبح
سلام خدمت دوستان

در قطع کد زیر :


<System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint:="GetThreadContext"), System.Security.SuppressUnmanagedCodeSecurity()>

همینجور که میبینید دو کلمه
kernel32.dll و
GetThreadContext به صورت String هستش!

خوب حالا من میخوام دو کلمه بالا رو یک فانکشن نوشته شده کد کنم و اینجوری به کار ببرم :


<System.Runtime.InteropServices.DllImport(decode("TT@ERS#"), EntryPoint:=decode("FSWEWERE")), System.Security.SuppressUnmanagedCodeSecurity()>

که فانکشن Decode الان همون
kernel32.dll و
GetThreadContext رو بر میگردونه اما با ارور زیر مواجه میشم :

Constant expression is required.

من این کد رو هم به کار بردم ولی نشد :




Dim cls as new Class 1
<System.Runtime.InteropServices.DllImport(cls.decod e("TT@ERS#"), EntryPoint:=cls.decode("FSWEWERE")), System.Security.SuppressUnmanagedCodeSecurity()>