Skip to content

Instantly share code, notes, and snippets.

@Ai-Himmel
Created February 20, 2019 05:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ai-Himmel/6026103950b31c1792ebe4a52f232138 to your computer and use it in GitHub Desktop.
Save Ai-Himmel/6026103950b31c1792ebe4a52f232138 to your computer and use it in GitHub Desktop.

foo.c

#include <stdio.h>
#include <stdio.h>
	__declspec(dllexport) void foo(char** str)
	{
		puts(*str);
	}

	__declspec(dllexport) void bar(char** ch)
	{
		putc(**ch,stdout);
	}
import ctypes
dll = ctypes.CDLL('./foo.dll')
test_str = ctypes.c_char_p('Hello World')
test_str_p = ctypes.pointer(test_str)
dll.foo(test_str_p)
test_char = ctypes.c_char('A')
test_char_p = ctypes.pointer(test_char)
test_char_pp = ctypes.pointer(test_char_p)
dll.bar(test_char_pp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment