c#,winapi,processes,privileges,createprocessasuserRelated issues-Collection of common programming errors


  • Bruno Brant
    c# visual-studio
    Confusing title, confusing question, but I hope I can get your attention. To the point:I have a VS solution with three projects. Project1: A Native DLL interop wrapper, which imports Native.dll. Project2: A WinForms project that make calls to the wrapper contained by Project1. Project3: A MSTest project that make calls to the wrapper contained by Project1 Project2.I have included Native.dll in the Project1, and configured it to be copied to the output folder. This setup will result in the DllImp

  • Kara
    c# vmware vix
    I’m developing a C# application which loads a C++ dll which opens VMware Player using VIX APIs. If the C++ dll is loaded by a C++ application then the virtual machine is loaded without problems, while when it is loaded by the C# application the function VihHost_Connect fails returning error 3 VIX_E_INVALID_ARG. I can’t figure out why the SAME dll works when loaded by a C++ application, but doesn’t work when loaded by the C# app. Any hints? Here it’s the code of the C# application.static class N

  • Santhosh
    c# c++ datetime
    I have a C++ client talking to a C# server and I have custom serialization for user defined types.Now I need to pass a date and time structure from C++ to C#. Googling led to the following approach:Fill up the date/time in SYSTEMTIME structure (This is not the current system time. But rather it will be filled up by the program based on certain conditions) Convert SYSTEMTIME to FILETIME Convert FILETIME to __int64 (this gives a 64 bit value representing the number of 100 nanoseconds interval fro

  • Danzomida
    c# database-connection connection-string sqlanywhere sybase-iq
    I’m trying to create an SAConnection into a Sybase IQ database. I’m attempting to create the connection through a simple visual studio C# application.My code fails at: SAConnection connection = new SAConnection(connString);And pops up with a message box: SQL Anywhere ADO.NET DataProviderFailed to load native dll (C:\Users\<Username>\AppData\Local\Temp\{16AA8FB8-4A98-4757-B7A5-0FF22C0A6E33}_0\dbdata.dllLink to picture of messageboxThe code subsequently throws an exception: “The type initial

  • Xcelled194
    c# c++ winapi dll
    This a question arising from this thread: Native C++ use C# dll via proxy C++ managed dllIn a nutshell, I’m loading (my) C# extension into a native process via a DLL. The extension needs to show a form so that the user can control it. I’m using standard .NET forms, no 3rd party librarys or anything, and my form is not showing up. Worse yet, it hangs the target process. It’s not using any CPU, so I get the feeling its waiting for some function to return, but never does.Also of interest is that th

  • user75569
    c# c++ windows-mobile native
    I have a windows mobile solution which contains two projects. One written in C# and another in C++ (unmaneged code that compiles into a dll). The part written in C# invokes some C++ functions from dll to connect to a server.If I open my application and I connect to the server everything works ok. If I minimize it , or if I open another windows mobile application over my application and try again to connect to the server it fails with a native exception code. (Exception code: 0xc000001d.)Any ide

  • torrential coding
    c# visual-studio-2010 dllimport
    I have used DLL Export viewer to try and find the functions that are in this DLL, I have found a list of functions and here it is:public: int __thiscall CSTVdsDisk::GetPartitionCount(void);the question is within in C# I am not able to call the function using either: [DllImport(“Some.dll”, ExactSpelling = true,EntryPoint = “GetPartitionCount”,CallingConvention = CallingConvention.StdCall,SetLastError = true)]or:[DllImport(“Some.dll”, ExactSpelling = true,EntryPoint = “CSTVdsDisk::GetPartitionCoun

  • krishna555
    c# visual-c++ c++-cli
    i have written a c++/cli program which calls my native c++ function which has the struct pointers as parameter to it. so its like i wrote a wrapper for my native c++ using c++/cli so that i can expose it to c# wcf program(which acts a server to another c++ client). now when i compile my c++/cli program, i didn’t get any errors and it got compiled and the dll for this c++/cli is generated, but when look at output window i see some thing like this failed in linking(which didn’t effect the compilat

  • Seth
    c# c++ interop c++-cli
    I have a mixed mode dll with native dll dependencies.I am loading the mixed mode dll from a C# exe using Assembly.Load. However, the location of the mixed mode dll is not in the application bin directory, therefore it fails because it only looks for the native C++ dll’s in the bin and the folders in the PATH environment variable.I thought using the option /assemblylinkresource was suppose to stop this and force the native dll’s to be found in the alternate directory alongside the deployed mixed

  • user3220513
    c# c++ wcf
    I run a WCF-Service in IIS-Express 8.0 and use Visual Studio 2010. The service calls a C++/CLI Wrapper, which calls the native C++ dll. If I start the client (C# Application), I am able to debug client, service and wrapper. If I try to step from the wrapper into the native C++ – Code, I fail. But from the return code I can see, that the function in the native C++ dll was called. In Addition: The native C++ dll is delay loaded from a path, I configure in the service via Global.asax-File. I also

  • Xcelled194
    c# c++ winapi dll
    This a question arising from this thread: Native C++ use C# dll via proxy C++ managed dllIn a nutshell, I’m loading (my) C# extension into a native process via a DLL. The extension needs to show a form so that the user can control it. I’m using standard .NET forms, no 3rd party librarys or anything, and my form is not showing up. Worse yet, it hangs the target process. It’s not using any CPU, so I get the feeling its waiting for some function to return, but never does.Also of interest is that th

  • adrian8400
    c++ debugging memory winapi
    I’m working with a single-threaded native c++ application. There is a very hard to reproduce bug that I cannot reproduce locally. I enabled full page heap and debug information in the release executable, and obtained dumps from a client (which has to use the application many days to get the bug).What the client reports: the application hangs and never recovers. It has to be killed from the task manager. What I see from the dumps: the application is stuck in an infinite loop.The loop is from wal

  • thudbang
    winapi
    Is it possible to wait for all processes launched by a child process in Windows? I can’t modify the child or grandchild processes.Specifically, here’s what I want to do. My process launches uninstallA.exe. The process uninistallA.exe launches uninstallB.exe and immediately exits, and uninstallB.exe runs for a while. I’d like to wait for uninstallB.exe to exit so that I can know when the uninstall is finished.

  • jesse
    windows winapi visual-c++ timer
    I faced a strange behavior with waitable timers. If I create it with one-second period then after the first firing, its following firings seem to be “aligned” to some millisecond value which differs significantly from first firing.Here is example of fire times (hours:minutes:seconds.milliseconds):18:06:25.753 <– here 753 18:06:26.238 <– here and later 238 18:06:27.238 18:06:28.238 18:06:29.238If I re-run the program, the millisecond value of first firing is different, but the subsequen

  • Jehjoa
    c++ windows winapi exception-handling
    I’m using a self written exception class called windows_error that inherits from std::runtime_error, which I use to, well, properly handle unexpected errors from Windows API functions.All the way on the bottom of the callstack, at the end of my WinMain function, I catch all windows_error exceptions that haven’t been dealt with yet. I intend to handle them by display an error message right before the program terminates, like so:int WINAPI wWinMain(HINSTANCE inst, HINSTANCE prev, wchar_t *cmdline,

  • Aczire
    c++ windows winapi error-handling
    Any idea why this happens? The method works flawlessly for the currentprocess and fails for remote process running on the same local machine with a garbage error code 2147483661 (0x80000000D) for me, since there is no hint at all anywhere about this particular error code, or am i missing something?. Also, I feel; since SymInitialize itself failed, and so is SymFromAddr. Am I correct?The process in question is running as admin and does have the SeDebug and SeSecurity Privileges.bool DbgHelpWrapp

  • James
    c++ c windows multithreading winapi
    I’d like to access a spawned process’s TIB (I created the process with CreateProcessW successfully).I have obtained a pointer to the spawned process’s TIB through:GetThreadContext (with permissions set of course) Accessing pContext.SegFs Formatting this value like so: (ldtSel.HighWord.Bits.BaseHi << 24 ) | ( ldtSel.HighWord.Bits.BaseMid << 16 ) | ( ldtSel.BaseLow ); (I don’t think this is necessary).The value I am left with after the format is a 10 digit pointer.How am I to use this

  • Gareth McCaughan
    windows winapi virtual-desktop
    [I have found the answer to this, but I’m asking it anyway so that if anyone else has the same problem they can find it. Answer to follow a minute or so after the question.]I’m hacking together something that lists every window on my Windows box, and it seems that for (only) one of my windows GetWindowRect is returning a rectangle with very negative y-coordinates.Possible complications: (1) I have multiple monitors but (1a) the y-coordinate is very negative, on the order of -24000, and (1b) othe

  • Sss
    c++ winapi stream dynamic-memory-allocation
    I have created preview handler for a file and when i click on that file i get the preview of that file in preview pane and what the scene behind is i read the file by creating a stream and and that stream i store in a buffer and then i play with the buffer contents in order to create the preview on preview pane.Now my question is that i want to allocate the size of that file(of which i have create dpreview handler) dynamically (using visual c++) so that i would not need to allocate the memory

  • user2808671
    c++ winapi
    If I write a simple code like this:int main(int argc, char* argv[]) {HANDLE hEvent = CreateEventW( NULL, FALSE, FALSE, L”EVENTTEST” );if (hEvent==NULL){cout<<“Error “<<GetLastError();}else{cout<<“Success”;}getch();return 0; }the code runs with success message but if I add some declaration in general scope above main (here I only add a line of code by declaring a bool variable) the function CreateEvenetW Fails with error code 998. If I use CreateEvent instead of CreateEventW no

  • Ganesh
    windows mfc winapi processes communication
    I need a way to store a value somewhere for temporarily by say Process A. Process A can exit the after storing the value in memory. After sometime Process B comes accesses the same location of memory and read the value. I need to store in memory, because I dont want the data to persistent across reboots. But as long as the system is up, it Independent of the Process the data must be accessible. I tried MailSlots and Temporary files in windows, both seem to have problem where the process referenc

  • marco.m
    c++ boost ipc processes
    I need a portable C++ library for doing IPC. I used fork() and SysV shared memory until now but this limits me to Linux/Unix. I found out that there are 3 major C++ libraries that offer a portable solution (including Windows and Mac OS X). I really like Boost, and would like to use it but I need processes and it seems like that this is only an experimental branch until now!? I have never heard of ACE or POCO before and thus I am stuck I do not know which one to choose. I need fork(), sleep() (us

  • dsolimano
    .net windows-services app-config processes
    I’m designing a windows service which is capable of starting up an arbitrary number of processes, each of which handle data processing on a different set of databases; sandboxes mirroring our live data processing service. The database connection information is stored in a config file, the location of which is specified in the app.config. Is it possible to change app.config data on a per-child-process basis?I have my MasterService, which, for instance, starts up 2 new processes: DataProcessor1

  • jjnguy
    c++ c windows command-line processes
    I have an application and I want to be able to check if (for instance) two instances of it used the same arguments on execution. To make it clearer:myapp 1 2myapp 1 3This isn’t a Singleton design pattern problem as I can have more than one instance running. I though about checking the running processes, but it seems that I can only get the process name and that doesn’t help me.Writing a file on startup and then having other instances check if that file exists isn’t viable due to abnormal program

  • Meltemi
    mysql unix processes mac-os-x-server
    I’m not a MySQL expert, it’s late and my eyes are batty. Now, with that out of the way… Something’s going screwy on this server and I’m wondering if maybe it’s the fact that there are two versions of MySQL on it and the old one (which is supposed to be dormant) is somehow coming back to life. I’m not sure I’m reading this output (below) correctly… There are two mysql entries…but I can’t be certain they’re both part of a normal healthy MySQL installation.usr/local/mysql/bin/mysqld is the ne

  • user133001
    c# multithreading processes
    I´m developing a software in C# that uses static functions from a C++ .dll file through a Wrapper. The problem is that some of these functions are slow and unstable, so in order to solve this I created a Thread that executes them. However, when I abort that thread from the main thread, the program isn´t letting me use those functions again, even though I define a new instance of the thread every time I call a function.Is there any way I can fix this? Thanks in advance.PS: Here is some code from

  • osgx
    c ipc processes shared-memory
    I am trying to communicate between two processes. I am trying to save data(like name, phone number, address) to shared memory in one process and trying to print that data through other process.process1.c#include <stdio.h> #include <sys/shm.h> #include <sys/stat.h> int main () {int segment_id;char* shared_memory[3];int segment_size;key_t shm_key;int i=0;const int shared_segment_size = 0x6400;/* Allocate a shared memory segment. */segment_id = shmget (shm_key, shared_segment_size

  • Minicl55
    c# processes explorer
    So my computer has a lot of errors. 99% of the time, they’re caused by explorer.exe being stupid. I can manually stop them, but I was thinking that I may be able to set up a schedule that automatically stops and starts it every 10 or so minutes, so I never have any problems with it any more. The code I have doesn’t work, but I’ll put it anyway:foreach (System.Diagnostics.Process myProc in System.Diagnostics.Process.GetProcesses()){if (myProc.ProcessName == “explorer.exe”){myProc.Kill();}}When I

  • Amy
    .net profiling processes
    Are there any built-in mechanisms in .Net that would allow us to write two programs, A and B. A is a process with special hooks onto which B attaches itself. This would allow B to gather whatever information those hooks provided.In particular, it would be nice to be able to dial into another of our process and gather suchs metrics like how many times a function was called in the last X minutes, the average run length, how many items are in this or that cache, etc.

  • Jelly Amma
    c# dll processes shared
    I have two different C# applications that are running at the same time.I would like both of them to be able to access the same “instance” of a DLL (also in C#).The DLL holds some data that I’d like to return to whichever of the two applications is asking for it.My DLL is thread-safe so I was hoping this would be possible but I’m not sure how.Any help or advice would be much appreciated.

  • Gilles
    permissions group privileges testing
    During the development of a script, some bugs remain “latent” until the script is run by a different user. (For example, the script may access a file that only the person developing the script has access to.)Is there a way to run the script with the same privileges that the “intended user” of the script would minimally have?(Please note the question’s wording. I specifically avoided writing “user with minimal privileges”, because in some cases the “intended user” may be expected to more than “

  • Arjan
    discussion privileges 10k-tools
    I think it’s a bit deceptive that a person works hard for months to get to the 10K tools, to have access to the moderator tools, to find out that all it is is analytical tools. While they are nice, I think it would be best if an appropriate name could be found for these tools, perhaps advanced statistics, or something like that.

  • Ronaldo Santana
    windows delphi manifest code-signing privileges
    My last question “List service and services status under Win-7” made me start working on a solution that gives my app the admin privileges under Windows Vista onward based on a .manifest file.I was not sure about continue the previous question with this matter since they are not the same so here is another question:My app now works fine under Win 7 whether or not I run it “as admin” because of the manifest file. My manifest file is as follow:<?xml version=”1.0″ encoding=”UTF-8″ standalone=”ye

  • slhck
    java osx privileges sudo
    I’m designing a little software in Java. I don’t know the term/definition to what I’m doing, but I’m prompting commands from Java to the terminal. Something like this:Process process = Runtime.getRuntime().exec(“command”);I’ve done this before in Linux, and I used gksudo for commands that required the root password.Is there any gksudo in OS X? Any graphical popup asking for root password?

  • George Duckett
    c# clickonce privileges administrator
    I need to give my application administrator rights, knowing that it will be run from a user session and not admin account.I’ve looked on other sites, but can’t find anything that helps.I tried editing the manifest among other things and there have inserted the line:<requestedExecutionLevel level=”requireAdministrator” uiAccess=”false” />This gave me an error when trying to publish using ClickOnce, but not when I debug.Can you help me?

  • Niels Keurentjes
    mysql database user privileges
    I have been playing around with user privileges in MySQL database and I still can not get desired result.Yesterday, I granted permissions, then revoked and the user did still have it. (same browser, only logged out). After restarting browser, it did work as expected.Today, I set privilegesGRANT CREATE ON `testdb`.`testtbl` TO ‘ttt’@’localhost’ IDENTIFIED BY ‘test’I didn’t see only “testdb”, but I saw table “test” too – and I shouldn’t. When I went to database “testdb”, I couldn`t create table. I

  • Raedwald

  • HaMster
    services installation privileges windows-server-2012
    This may sound like a trivial question but here is what is happening:I grab the latest version of Jenkins as native installer for Windows (1.491 in my case) I set up a Windows Server 2012 (official release image, no release candidate) and install all updates I try to run the Jenkins installation.Everything is working fine in the installation process except for the part where it tries to start the service. At this point I get informed that I have not sufficient privileges to start system services

  • Marius
    linux ssh privileges
    I have a Debian server, and I want to give several users read only access to a subtree of folders on that server. Is there a way to do this without manually changing the rights of all files and folders?

  • quanta
    linux root openvz privileges vim
    Since pty is limited, I want to modify the content of /proc/sys/kernel/pty/max. The original value in max is 4096, and now I want to modify it to 10000.[root@home pty]# pwd /proc/sys/kernel/pty [root@home pty]# ls -lh total 0 -rw-r–r– 1 root root 0 Aug 13 11:24 max -r–r–r– 1 root root 0 Aug 13 11:24 nr vim maxI edit the max file directly, using root, but it fails. I use :w! in vim, but then I see the following picture:so I tried to chmod max first, but that also failed:[root@home pty]# chmo

  • Jader Dias
    c# .net process createprocessasuser
    I tried var process = new Process {StartInfo = new ProcessStartInfo{FileName = filename,UserName = “System”,UseShellExecute = false,}, };process.Start();but it yieldsWin32Exception was unhandledLogin failed: unknown user name or wrong passwordI will have to use CreateProcessAsUser? How can I get the appropriate parameters to pass to that method?

  • Martin
    c# winapi processes privileges createprocessasuser
    I’ve been attempting to create a new process under the context of a specific user using the CreateProcessAsUser function of the Windows API, but seem to be running into a rather nasty security issue…Before I explain any further, here’s the code I’m currently using to start the new process (a console process – PowerShell to be specific, though it shouldn’t matter).private void StartProcess(){bool retValue;// Create startup info for new console process.var startupInfo = new STARTUPINFO();startup

Web site is in building