[Solved] Get a list of all excel processes started by winform application

[ad_1] Okay I have found the answer myself. I am sharing it just in case someone needs it. int myappid = Process.GetCurrentProcess().Id; Process[] processes = Process.GetProcessesByName(“EXCEL”); foreach (Process prs in processes) { var query = string.Format(“SELECT ParentProcessId FROM Win32_Process WHERE ProcessId = {0}”, prs.Id); var search = new ManagementObjectSearcher(“root\\CIMV2”, query); var results = search.Get().GetEnumerator(); results.MoveNext(); … Read more

[Solved] discussion about the scenarios that the insertion function of an STL vector may not work [closed]

[ad_1] I can only assume that a side effect of calculateSomeValue() is changing a which invalidates all iterators. Since the order of evaluation of arguments in a.insert(a.begin(), calculateSomeValue()); is unspecified it could be that a.begin() is evaluated before calculateSomeValue() invalidates all iterators to a. Which is undefined behaviour. [ad_2] solved discussion about the scenarios that … Read more

[Solved] Method that operates in a specific object (textBox)

[ad_1] Well…this question raises plenty of others, but if you’re wanting to check if an object passed into a method is a TextBox, and then to set the Text property of that, you’d need: private void ChangeText(object target) { var tBox = target as TextBox; if (tBox != null) tBox.Text = “new value”; } EDIT … Read more

[Solved] strcmp in a function in c++ [closed]

[ad_1] You can’t insert boolean conditions into the function this way: if (!strcmp( yn , “y” || yn , “Y”)) change the conditions to first evaluate the boolean result of the functions and then perform your logical comparison if (!strcmp(yn , “y”) || !strcmp(yn , “Y”)) Also notice that you’re missing #include <cstring> to use … Read more

[Solved] C++: Update to memory location using pointer is lost [closed]

[ad_1] This is bad: void TestLocalQueue::putMsg(){ ControlCommand cc; cc.setDynamic(“target”); cout<<“Setting Dynamic context \n”<<endl; localQueue->put(&cc ); The localQueue->put function stores the pointer you give it into the queue. However cc‘s lifetime is only for the duration of the putMsg function, so when this function exits you will have a dangling pointer. To fix this you could … Read more

[Solved] c# bit shift task with integers

[ad_1] What does this code do? How would have you named such a function? I would have named it so /// <summary> /// Convert an Int32 value into its binary string representation. /// </summary> /// <param name=”value”>The Int32 to convert.</param> /// <returns>The binary string representation for an Int32 value.</returns> public String ConvertInt32ToBinaryString(Int32 value) { String … Read more

[Solved] Investment balance in c#?

[ad_1] Console.Write(“Enter the amount deposited: “); double principle = 0; principle = double.Parse(Console.ReadLine()); Console.Write(“Enter number of years: “); int years = 0; years = int.Parse(Console.ReadLine()); Console.Write(“Enter the interest rate as a percentage of 1.0: “); double interest; interest = double.Parse(Console.ReadLine()); double balance = 0; Console.WriteLine(“Years \t Balance”, years); for (int i = 0; i < … Read more

[Solved] Сhanging even and odd characters in a string array

[ad_1] Without code we can’t really help you fix it… but here is a solution: #include <stdio.h> #include <string.h> int main() { char str[11] = “HelloWorld”; for(int i = 0; i < strlen(str); i += 2) { char tmp = str[i]; str[i] = str[i+1]; str[i+1] = tmp; } printf(“%s”, str); return 0; } Output: eHllWorodl … Read more

[Solved] I don’t find the error

[ad_1] try this correction to your program #include <stdio.h> #include <stdlib.h> /* * */ #define NB_MESURES 50 int main(int argc, char** argv) { int i=0; float measure[NB_MESURES] /* NB_MESURES is predefined to be 50*/ ,sum=0,average=0; char sex=0; char yn=0; while(1){ /*endless loop (1)*/ printf(“Persoa %d”,i); printf(“\nIndique se é home (H) ou muller (M): “); while(1) … Read more

[Solved] Make a new pointer in a loop C

[ad_1] i and id are both local variables with automatic storage (commonly referred to as on the stack). No new instances are created upon each iteration of the loop, the same space is reused and a new value is stored in id, hence the same addresses printed by printf. Note that the value of id … Read more