shell32: Implement CommDlgBrowser::OnDefaultCommand in the ExplorerBrowser control.
[wine] / dlls / mscoree / tests / mscoree.c
1 /*
2  * Copyright 2010 Louis Lenders
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "wine/test.h"
20
21 static HMODULE hmscoree;
22
23 static HRESULT (WINAPI *pGetCORVersion)(LPWSTR, DWORD, DWORD*);
24 static HRESULT (WINAPI *pGetCORSystemDirectory)(LPWSTR, DWORD, DWORD*);
25
26 static BOOL init_functionpointers(void)
27 {
28     hmscoree = LoadLibraryA("mscoree.dll");
29
30     if (!hmscoree)
31     {
32         win_skip("mscoree.dll not available\n");
33         return FALSE;
34     }
35
36     pGetCORVersion = (void *)GetProcAddress(hmscoree, "GetCORVersion");
37     pGetCORSystemDirectory = (void *)GetProcAddress(hmscoree, "GetCORSystemDirectory");
38     if (!pGetCORVersion || !pGetCORSystemDirectory)
39     {
40         win_skip("functions not available\n");
41         FreeLibrary(hmscoree);
42         return FALSE;
43     }
44
45     return TRUE;
46 }
47
48 static void test_versioninfo(void)
49 {
50     WCHAR version[MAX_PATH];
51     WCHAR path[MAX_PATH];
52     DWORD size, path_len;
53     HRESULT hr;
54
55     hr =  pGetCORVersion(NULL, MAX_PATH, &size);
56     ok(hr == E_POINTER,"GetCORVersion returned %08x\n", hr);
57
58     hr =  pGetCORVersion(version, 1, &size);
59     ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER),"GetCORVersion returned %08x\n", hr);
60
61     hr =  pGetCORVersion(version, MAX_PATH, &size);
62     ok(hr == S_OK,"GetCORVersion returned %08x\n", hr);
63
64     trace("latest installed .net runtime: %s\n", wine_dbgstr_w(version));
65
66     hr = pGetCORSystemDirectory(path, MAX_PATH , &size);
67     ok(hr == S_OK, "GetCORSystemDirectory returned %08x\n", hr);
68     /* size includes terminating null-character */
69     ok(size == (lstrlenW(path) + 1),"size is %d instead of %d\n", size, (lstrlenW(path) + 1));
70
71     path_len = size;
72
73     hr = pGetCORSystemDirectory(path, path_len-1 , &size);
74     ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "GetCORSystemDirectory returned %08x\n", hr);
75
76     hr = pGetCORSystemDirectory(NULL, MAX_PATH , &size);
77     ok(hr == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), "GetCORSystemDirectory returned %08x\n", hr);
78
79     hr = pGetCORSystemDirectory(path, MAX_PATH , NULL);
80     ok(hr == E_POINTER,"GetCORSystemDirectory returned %08x\n", hr);
81
82     trace("latest installed .net installed in directory: %s\n", wine_dbgstr_w(path));
83 }
84
85 START_TEST(mscoree)
86 {
87     if (!init_functionpointers())
88         return;
89
90     test_versioninfo();
91
92     FreeLibrary(hmscoree);
93 }