当前位置:   article > 正文

Android C 语言读取系统属性___system_property_get

__system_property_get

    用 Qt Creator 写一个 Android 程序,需要读取 DNS 。C 语言怎么读呢,研究了一下,原来在 Android 的 C 库里,就有读取系统属性的方法。用 objdump 看了一下 libc.so ,找到了其中的函数。如下:

  1. 000095f0 g F .text 00000014 __system_properties_init
  2. 00009604 g F .text 00000014 __system_property_find
  3. 00009618 g F .text 00000014 __system_property_find_nth
  4. 0000962c g F .text 00000014 __system_property_get
  5. 00009640 g F .text 00000014 __system_property_read
  6. 00009654 g F .text 00000014 __system_property_wait

    头文件是 system_properties.h ,在 usr/include/sys目录下面。

    __system_property_get 可以用来获取一个属性值,函数原型如下:

  1. /* Look up a system property by name, copying its value and a
  2. ** \0 terminator to the provided pointer. The total bytes
  3. ** copied will be no greater than PROP_VALUE_MAX. Returns
  4. ** the string length of the value. A property that is not
  5. ** defined
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/43422
推荐阅读
相关标签
  

闽ICP备14008679号