Notice
Recent Posts
Recent Comments
Link
일상생활
Connecting Dll from Flutter 본문
1. 패키지 설치
pubspec.yaml 에 다음과 같이 패키지를 추가합니다.
dependencies:
flutter:
sdk: flutter
ffi: ^2.0.1 # 최신 버전 확인 후 입력
charset_converter: ^2.0.1 # cp949
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.6
intl: ^0.18.0
dev_dependencies:
flutter_test:
sdk: flutter
ffi: ^2.0.1 # 최신 버전 확인 후 입력
charset_converter: ^2.0.1 # cp949
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^3.0.0
intl: ^0.18.0
추가하고 패키지를 설치합니다.
$ flutter pub get
2. DLL 선언
import 'dart:convert';
import 'dart:ffi';
import 'dart:io';
import 'package:ffi/ffi.dart';
import 'dart:typed_data';
import 'package:charset_converter/charset_converter.dart';
// DLL 파일 로드
final DynamicLibrary kisPosAgentLibrary = DynamicLibrary.open('Dll.dll');
typedef CInitDll = Int32 Function();
typedef DartInitDll = int Function();
final DartInitDll initDll = DllLibrary
.lookup<NativeFunction<CInitDll>>('InitDll')
.asFunction<DartInitDll>();
3. mart.dart 연결하기
// InitDll 호출
final initResult = initDll();
print('InitDll result: $initResult');
if (initResult != 0) {
print('InitDll failed with code: $initResult');
return;
}
반응형
'tech' 카테고리의 다른 글
2024년 6대 과학기술 주력분야 주요뉴스 발표 (0) | 2025.01.27 |
---|---|
Web2App 호출 (0) | 2025.01.22 |
.Net 6.0 에서 NullReferenceException 인 경우 (0) | 2025.01.22 |
visual studio 2022에서 CS0234 오류인 경우 (0) | 2025.01.22 |
Connecting websocket from Flutter (0) | 2025.01.22 |