Skip to content

How to use .NET Attributes #1929

Answered by Lamparter
knowwy asked this question in Q&A
Mar 18, 2025 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

I think they can be used like:

from System.Runtime.InteropServices import DllImportAttribute, PreserveSigAttribute
DllImport = clrtype.attribute(DllImportAttribute)
PreserveSig = clrtype.attribute(PreserveSigAttribute)

@staticmethod
@DllImport("user32.dll")
@PreserveSig()
@clrtype.accepts(System.IntPtr, System.String, System.String, System.UInt32)
@clrtype.returns(System.Int32)
def MessageBox(hwnd, text, caption, type): #body

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@knowwy
Comment options

@Lamparter
Comment options

@Lamparter
Comment options

@Lamparter
Comment options

Answer selected by knowwy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants