Hi,
habe im FAQ bereich was zum DLL erstellen gefunden.
Habe mir dann mal zum Testen ne eigene DLL geschrieben(Eigentlich wollte ich ja nur die API Testen):
main.cpp:
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#include <Windows.h>
#include <iostream>
#include <fstream>
using namespace std;
extern "C"
{
// Prototypen
TEST_API void ausgabe(char cText[2048]);
TEST_API void DllWriteToLog(char cText[2048]);
#define TEST_EXPORTS
BOOL APIENTRY DllMain(HMODULE hModule,
DWORD dwReason_For_Call,
LPVOID pvReserved)
{
switch(dwReason_For_Call)
{
case DLL_PROCESS_ATTACH:
// DLL wird geladen
break;
case DLL_PROCESS_DETACH:
// DLL wird entladen
break;
}
return TRUE;
}
#ifdef TEST_EXPORTS
#define TEST_API __declspec(dllexport)
#else
#define TEST_API __declspec(dllimport)
#endif
TEST_API void ausgabe(char cText[2048])
{
cout << cText << "\n";
}
TEST_API void DllWriteToLog(char cText[2048])
{
// Objekt der Klasse fstream erzeugen
fstream log;
// Logbuchdatei öffnen
log.open("log.txt", ios::out);
// Informationen ins Logbuch schreiben
log << cText << "\n";
// Logbuchdatei schliessen
log.close();
}
}
|
Beim Compilliieren kommen die Folgenden Fehler:
|
Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
------ Build started: Project: Forum, Configuration: Debug Win32 ------
Compiling...
main.cpp
z:\forum\main.cpp(12) : error C2144: syntax error : 'void' should be preceded by ';'
z:\forum\main.cpp(12) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
z:\forum\main.cpp(13) : error C2144: syntax error : 'void' should be preceded by ';'
z:\forum\main.cpp(13) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
z:\forum\main.cpp(13) : error C2086: 'int TEST_API' : redefinition
z:\forum\main.cpp(12) : see declaration of 'TEST_API'
z:\forum\main.cpp(54) : error C2375: 'ausgabe' : redefinition; different linkage
z:\forum\main.cpp(12) : see declaration of 'ausgabe'
z:\forum\main.cpp(62) : error C2375: 'DllWriteToLog' : redefinition; different linkage
z:\forum\main.cpp(13) : see declaration of 'DllWriteToLog'
Build log was saved at "file://z:\Forum\Debug\BuildLog.htm"
Forum - 7 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
Kann mir da Jemand helfen?
mfg,
Faule Socke