<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.haidhi.my.id/wiki/index.php?action=history&amp;feed=atom&amp;title=Cara_membuat_DLL_sendiri</id>
	<title>Cara membuat DLL sendiri - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.haidhi.my.id/wiki/index.php?action=history&amp;feed=atom&amp;title=Cara_membuat_DLL_sendiri"/>
	<link rel="alternate" type="text/html" href="https://wiki.haidhi.my.id/wiki/index.php?title=Cara_membuat_DLL_sendiri&amp;action=history"/>
	<updated>2026-11-01T22:44:31Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://wiki.haidhi.my.id/wiki/index.php?title=Cara_membuat_DLL_sendiri&amp;diff=186&amp;oldid=prev</id>
		<title>SanzSkuy: Created page with &quot;&lt;syntaxhighlight lang=cpp line&gt; // mylib.cpp  #include &lt;windows.h&gt;   #define EOF (-1)   #ifdef __cplusplus    extern &quot;C&quot; {         #endif   __declspec(dllexport) int tambah(int a, int b) {     return a + b; }  __declspec(dllexport) int factorial(int a){     int result = 1;     for(int i = 1; i &lt;=a; i++){         result *= i;     }     return result; }  #ifdef __cplusplus  } #endif &lt;/syntaxhighlight&gt; compile  &lt;syntaxhighlight lang=powershell&gt;  # Akan menghasilkan file myl...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.haidhi.my.id/wiki/index.php?title=Cara_membuat_DLL_sendiri&amp;diff=186&amp;oldid=prev"/>
		<updated>2025-04-10T06:39:56Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;syntaxhighlight lang=cpp line&amp;gt; // mylib.cpp  #include &amp;lt;windows.h&amp;gt;   #define EOF (-1)   #ifdef __cplusplus    extern &amp;quot;C&amp;quot; {         #endif   __declspec(dllexport) int tambah(int a, int b) {     return a + b; }  __declspec(dllexport) int factorial(int a){     int result = 1;     for(int i = 1; i &amp;lt;=a; i++){         result *= i;     }     return result; }  #ifdef __cplusplus  } #endif &amp;lt;/syntaxhighlight&amp;gt; compile  &amp;lt;syntaxhighlight lang=powershell&amp;gt;  # Akan menghasilkan file myl...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=cpp line&amp;gt;&lt;br /&gt;
// mylib.cpp&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;windows.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
#define EOF (-1)&lt;br /&gt;
 &lt;br /&gt;
#ifdef __cplusplus   &lt;br /&gt;
extern &amp;quot;C&amp;quot; {        &lt;br /&gt;
#endif&lt;br /&gt;
 &lt;br /&gt;
__declspec(dllexport) int tambah(int a, int b) {&lt;br /&gt;
    return a + b;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
__declspec(dllexport) int factorial(int a){&lt;br /&gt;
    int result = 1;&lt;br /&gt;
    for(int i = 1; i &amp;lt;=a; i++){&lt;br /&gt;
        result *= i;&lt;br /&gt;
    }&lt;br /&gt;
    return result;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#ifdef __cplusplus&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
compile &lt;br /&gt;
&amp;lt;syntaxhighlight lang=powershell&amp;gt; &lt;br /&gt;
# Akan menghasilkan file mylib.dll&lt;br /&gt;
g++ -shared -o mylib.dll mylib.cpp&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=cpp line&amp;gt;&lt;br /&gt;
// main.cpp&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;windows.h&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
typedef int (*TambahFunc)(int, int);&lt;br /&gt;
typedef int(*FactorialFunc)(int);&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
    HINSTANCE hDll = LoadLibrary(&amp;quot;mylib.dll&amp;quot;);&lt;br /&gt;
    if (!hDll) {&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; &amp;quot;Gagal load DLL&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
        return 1;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    TambahFunc tambah = (TambahFunc)GetProcAddress(hDll, &amp;quot;tambah&amp;quot;);&lt;br /&gt;
    if (!tambah) {&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; &amp;quot;Gagal cari fungsi tambah&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
        return 1;&lt;br /&gt;
    }&lt;br /&gt;
    int hasil = tambah(5, 7);&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Hasil: &amp;quot; &amp;lt;&amp;lt; hasil &amp;lt;&amp;lt; std::endl; &lt;br /&gt;
&lt;br /&gt;
    FactorialFunc factorial = (FactorialFunc)GetProcAddress(hDll, &amp;quot;factorial&amp;quot;);&lt;br /&gt;
    if (!factorial){&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; &amp;quot;Gagal cari fungsi factorial&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
        return 1;&lt;br /&gt;
    }&lt;br /&gt;
    int hasil2 = factorial(5);&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;Hasil2: &amp;quot; &amp;lt;&amp;lt; hasil2 &amp;lt;&amp;lt; std::endl; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    FreeLibrary(hDll);&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
compile &amp;amp; run &lt;br /&gt;
&amp;lt;syntaxhighlight lang=powershell&amp;gt; &lt;br /&gt;
g++ main.cpp -o main.exe&lt;br /&gt;
main.exe&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>SanzSkuy</name></author>
	</entry>
</feed>