Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 437 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
437
Dung lượng
3,92 MB
Nội dung
[...]... from the compiler The “Understanding the Effects of Pointers” section tells you about managed alternatives that mimic pointers In short, while unsafe code is a necessity when working with theWin32 API, you should avoid it whenever possible Understanding the Effects of Pointers One ofthe first issues that you’ll face when working with theWin32API is the use of pointers theWin32API uses them by the. .. to theWin32API Given the current state ofthe NET Framework, I’m betting that most NET developers will need some type of access to theWin32 API, and this book explores the issue at all levels All ofthe examples contain full explanations, and for each, you’ll find both the source and the compiled example on the CD that accompanies this book You won’t find any information on using the language of. .. you’ll find that you can’t use the full−featured function because the target language won’t support it Win32 Function Types One ofthe problems in determining if a piece of functionality is missing from the NET Framework is that theframework is relatively large—not as large as theWin32 API, but large nonetheless (At the time of this writing, the download size for the NET Framework was 21 MB.) So it... in the NET Framework most often The following sections discuss the various places where other developers have found holes in the NET Framework coverage oftheWin32API You might find other areas when working with special Win32API features, but these sections provide you with a fairly complete overview Hardware Every time Microsoft releases a new technology, they find a way to add yet more layers of. .. that Microsoft has implemented some, but not all, of the Win32 API in the NET Framework In some cases, you might find that Microsoft mislaid the feature in an out ofthe way spot, but more often than not, the feature is simply missing It’s not documented anywhere and Microsoft doesn’t give you even one clue as to where the feature might have gone A visit to the newsgroups will often yield a pathetic claim... btnTest_Click() accesses the input value, converts it to an int, and supplies the address ofthe int to the DoTimeIt() method Because we’ve supplied an address, rather than the value, any change in the supplied value by DoTimeIt() will remain when the call returns The DoTimeIt() method accesses the current time, multiplies it by the value ofthe input string, and then outputs the value Notice the use of pointers... Limitations The biggest limitations for Visual Basic NET developers are lack of unsafe code and lack of pointer support You can get around some of these limitations using the techniques in the “Understanding the Effects of Pointers” section of the chapter Essentially, you need to be able to provide the input to theWin32API call using something other than a pointer, which often means a either compromise... circumvent the requirement to access theWin32API just to create a beep The technique is important because it provides you with another choice; one that doesn’t rely on unmanaged code TheWin32API Beep() function has the advantage of providing the greatest flexibility for the smallest cost in resources To use this technique, you must declare theWin32API Beep() function as a DLL import using the [DllImport]... to the documentation Given the amount of work Microsoft is doing with language specific features, you should expect to see this variable implemented sometime in the future The btnTest_Click() shows off a few of the unique features of the MessageBoxEx() function Figure 2.1 shows the output of this code Notice that the message box has four buttons and that we selected the Continue button as default The. .. includes a Beep() function as part of the language, it doesn’t require any special programming to access this Win32API feature In sum, the question of missing functionality is a matter of determining if the language you’re using provides the feature and then determining the best method to access the feature if it is missing You’ll find that the question ofWin32API access becomes more complex as . An Overview of the Win32 API 5 Chapter 1: Overcoming Holes in the .NET Framework 6 Overview 6 Why Access the Win32 API? 6 A Case of Missing Functionality 7 Win32 Function Types 8 Win32 Access. Microsoft has implemented some, but not all, of the Win32 API in the .NET Framework. In some cases, you might find that Microsoft mislaid the feature in an out of the way spot, but more often. exploit the Software, or any portion thereof, without the written consent of SYBEX and the specific copyright owner(s) of any component software included on this media. In the event that the Software