Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3855632
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:48:21+00:00 2026-05-19T17:48:21+00:00

I have the following code that works under linux. I want to port it

  • 0

I have the following code that works under linux. I want to port it to Windows
but i have no idea where to look for.

import os
import sys
import ctypes 
import ctypes.util
MAX_CHARS = 1000    # maximum number of characters to read

if __name__ == "__main__":
    libc = ctypes.CDLL("libc.so.6") # LINUX
    fd = libc.open(sys.argv[0], os.O_RDONLY)
    buffer = " " * MAX_CHARS
    num_chars_read = libc.read(fd, buffer, MAX_CHARS)
    print buffer[:num_chars_read]
    libc.close(fd)

    # ALL OF THIS GIVES WRONG DLL's 'UNDER WINDOWS
    #libc = ctypes.CDLL(ctypes.util.find_library('c'))
    #libc =  ctypes.windll.kernel32 # WINDOWS
    #libc =  ctypes.windll.user32 # WINDOWS
    #libc =  ctypes.windll.shell32 # WINDOWS
    #libc =  ctypes.windll.gdi32 # WINDOWS
#libc =  ctypes.cdll.msvcrt # WINDOWS

Any idea in which DLL i need to look for ‘open’ and ‘read’ calls?

Many thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T17:48:22+00:00Added an answer on May 19, 2026 at 5:48 pm

    These slides indicate that this will work:

    >>> from ctypes import *
    >>> libc = cdll.msvcrt
    

    I can then access libc.printf, and libc.fopen, but not open or read, though libc._open and libc._read are available. Perhaps an issue with calling conventions?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query that works under Hibernate but not under eclipse: select
I have the following code that works on PHP5 to send a HTTP POST
I have the following code that works on Firefox and Chrome $("#adicionarItem").click(function(){ $.ajax({ type:
I have the following code that works fine in IE: <HTML> <BODY> <script language=JavaScript>
I have the following code that compiles and works well: template<typename T> T GetGlobal(const
I have some JavaScript code that works in IE containing the following: myElement.innerText =
I have the following code: Bear in mind that while this code works on
I have code that looks like the following, which works fine for displaying the
I have some piece of code that behaves differently under Mac OSX and Linux
I have an asp.net mvc application that works fine under visual studio but when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.