![]() ![]() ![]() _tprintf(TEXT("Terminal failure: Unable to open file \"%s\" for write.\n"), argv) HFile = CreateFile(argv, // name of the write Printf("Usage Error:\tIncorrect number of arguments\n\n") ![]() Int _cdecl _tmain(int argc, TCHAR *argv)Ĭhar DataBuffer = "This is some test data to write to the file." ĭWORD dwBytesToWrite = (DWORD)strlen(DataBuffer) The following example uses CreateFile to create a new file and open it for writing and WriteFile to write a simple string synchronously to the file.Ī subsequent call to open this file with CreateFile will fail until the handle is closed. When an application creates a new file, the operating system adds it to the specified directory. You must specify the file name, creation instructions, and other attributes. There are two more things to do before you can use your new extension: compilingĪnd linking it with the Python system.The CreateFile function can create a new file or open an existing file. PyInit_spam, and creation of the module is left to the import machinery.įor details on multi-phase initialization, see PEP 489. (new in Python 3.5), where a PyModuleDef structure is returned from Unlike our spam example, xxmodule uses multi-phase initialization Optionally followed by an import of the module: To add the module to the initialization table, use PyImport_AppendInittab(), When embedding Python, the PyInit_spam() function is not calledĪutomatically unless there’s an entry in the PyImport_Inittab table. So that it then gets inserted into sys.modules. The init function must return the module object to its caller, It may abort with a fatal error forĬertain errors, or return NULL if the module could not be initialized ![]() PyModule_Create() returns a pointer to the module object Table (an array of PyMethodDef structures) found in the module definition. Inserts built-in function objects into the newly created module based upon the It calls PyModule_Create(), which returns a module object, and (See below for comments about embedding Python.) When the Python program imports module spam for the first time, Note that PyMODINIT_FUNC declares the function as PyObject * return type,ĭeclares any special linkage declarations required by the platform, and for C++ Static PyObject * spam_system ( PyObject * self, PyObject * args ) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |