Apply attributes to Win32 API 
Author Message
 Apply attributes to Win32 API

Hi,

How can one apply attributes on Win32 API calls such as
[SuppressUnmanagedCodeSecurityAttribute()]

::Sleep(DWORD dwMilliseconds);

Thanks.



Tue, 18 Oct 2005 01:17:00 GMT  
 Apply attributes to Win32 API
Egbert,

Quote:
>How can one apply attributes on Win32 API calls such as
>[SuppressUnmanagedCodeSecurityAttribute()]

>::Sleep(DWORD dwMilliseconds);

Custom attributes can only be applied to metadata entities (such as a
method declaration), not to method calls or other code. You'd have to
write a P/Invoke (DllImport) declaration with the attributes you want
for Sleep and call that.

But if you're in managed code, why not call
System::Threading::Thread::Sleep instead?

Mattias

===

http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.



Tue, 18 Oct 2005 06:46:22 GMT  
 Apply attributes to Win32 API

Quote:
> Egbert,

> >How can one apply attributes on Win32 API calls such as
> >[SuppressUnmanagedCodeSecurityAttribute()]

> >::Sleep(DWORD dwMilliseconds);

> Custom attributes can only be applied to metadata entities (such as a
> method declaration), not to method calls or other code. You'd have to
> write a P/Invoke (DllImport) declaration with the attributes you want
> for Sleep and call that.

> But if you're in managed code, why not call
> System::Threading::Thread::Sleep instead?

Mattias,

of course, it was just a sample.
Thanks for your answer. Did not know that DllImport also worked for C++

--

Quote:

> Mattias

> ===

> http://www.msjogren.net/dotnet/
> Please reply only to the newsgroup.



Tue, 25 Oct 2005 01:21:32 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Getting the type an attribute applies to

2. Getting the object that an attribute applies to

3. ::PostMessage Win32 API equivalent??

4. .NET classes win32 api reference

5. using a win32 api in managed code

6. Problem marshalling complex structures (invoking Win32 APIs)

7. How printing in landscape mode using win32 api?

8. How to call Win32 API??

9. Win32 API, MFC and ATL are DEAD

10. struct pointers, how? (importing functions from win32 api)

11. Win32 API Call

12. Printing using the Win32 API in C#

 

 
Powered by phpBB® Forum Software