Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

How to initialize LPBOOL? Win32 Api in Kotlin Native #2042

Closed
PramUkesh opened this issue Sep 11, 2018 · 4 comments
Closed

How to initialize LPBOOL? Win32 Api in Kotlin Native #2042

PramUkesh opened this issue Sep 11, 2018 · 4 comments

Comments

@PramUkesh
Copy link

How to Initialise this in Kotlin Native

    val result = CopyFileExA(
                          oldFile,
                          newFile,
                          null,
                          null,
                          false,
                          COPY_FILE_FAIL_IF_EXISTS
                         )

while false is not accepted as LPBOOL? How to initialize LPBOOL? in kotlin Native

i was getting following error :

the boolean literal does not conform to the expected type

LPBOOL? /* = CPointer */>? */ false,

@olonho
Copy link
Contributor

olonho commented Sep 11, 2018

Sure, LPBOOL is pointer to C BOOL, see https://github.com/JetBrains/kotlin-native/blob/master/INTEROP.md#passing-pointers-to-bindings for details how to create and pass pointers.

@olonho olonho closed this as completed Sep 11, 2018
@PramUkesh
Copy link
Author

not able to figure how to do that help me please

@PramUkesh
Copy link
Author

@olonho

@olonho
Copy link
Contributor

olonho commented Sep 12, 2018

import kotlinx.cinterop.*
import platform.windows.*

fun main(args: Array<String>) {
  memScoped {
    val bool = alloc<BOOLVar>()
    bool.value = TRUE
    CopyFileExA("from", "to", null, null, bool.ptr, 0)
  }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants